my task is to type 20 integer numbers from 0 to 99 as the input data.
few tasks are to check the maximum and minimum, and find the total number of even and odd numbers. (this one i already got the answer). But i have problem for my next task, which is to display prime numbers from the input data.
this is what i've done. and i dont know how to check the prime numbers. hope someone can help me.
#include <iostream>
#include <conio.h>
using namespace std;
void main()
{
int i,j,n=10, max=0, min=99, x, even=0, odd=0, prime=0; // x0=0,x1=0, x2=0, x3=0, x4=0; prime=2;
cout << "Enter 20 integer numbers from 0 to 99: "<<endl;
for (i=1;i<=n;i++)
{
cout << "Input " << i <<":";
cin >> x;
if (x>max)
max=x;
if (x<min)
min=x;
if (x%2==0)
even++;
else
odd++;
if (x%x==0 && x%1==x)
prime=x;
if(prime)
{
cout << i << " is prime" << endl;
}
}
cout<<"max is"<<max<<endl;
cout<<"min is"<<min<<endl;
cout<<"Total number of even is "<<even<<endl;
cout<<"Total number of odd is "<<odd<<endl;
getch();
}