Finding if a number is prime or not



cin.ignore (10);
return 0;
}



Its not working
Last edited on
Hey I M sending u a program to check whether number is prime or not
//Find Number is Prime or not
#include <iostream.h>
#include <conio.h>
main()
{
int a,b,rem=1,x;
char chr;
do{
cout<<"\nEnter any number to check is Prime or not : ";
cin>>a;
x=a;
for (b=1;b<x;b++)
{
if(a%b==0&&a/a==1&&a/1==a)
{
rem++;
}
}
if(rem==2)
{
cout<<"\t"<<a<<" Is Prime";
}
else{
cout<<"\t"<<a<<" Is Not Prime\n";
}
cout<<"\nDo u want more to check press\ty\nor press n:\t";
cin>>chr;
}while(chr=='y' || chr=='Y');
cout<<"\n Press any key to exit\n";
getch();
return 0;
}
Topic archived. No new replies allowed.