{
int n,i,rem=0;
cout<<"Enter the number U want to check"; cin>>n;
if(n==0)
cout<<"The number is not prime";
if(n==1)
cout<<" The number is prime";
if(n==2)
cout<<"The number is even-prime;
else
if((n!=0) && (n!=1) && (n!=2))
{
for(i=2; i
rem=n%i;
if(rem==0)
{
break;//come out of for loop
}
}
}
if(rem==0)
{
Cout<<"The number is not a prime";
}
else
if(rem!=0)
{
cout<<"The num is a prime";
}
getch();
}
No comments:
Post a Comment