The
following is
c++ code for
finding whether or not a
number is
prime:
#include <iostream.h>
/* Program that finds whether a number is prime or not.*/
int main ()
{
int number, notprime, P;
cout << "Enter integer ";
cin >> number; //takes in an integer to test if it's a prime
P=2;
do{ //section for finding whether or not selected integer is a prime
if (number%P==0)
notprime = 1;
else
P++;
}while ((P<=sqrt(number))||(notprime==1));
if (notprime==1)
cout << "Not prime";
else
cout << "Prime";
return (0);
}