To check if the number is prime or not.





Code:
/*
    To check if an integer is prime or not
*/

#include<iostream.h>
#include<conio.h>
void main()
{
int num,i; clrscr(); cout<< "Please enter the number "; cin >> num; i =2 ; while(1){
if (num%i==0) {
if(num == i){
cout << "Prime Number"; break;
} else {
cout << "Not Prime"; break;
}
} else {
i++;
}
}
}