/* isPrime-v1.cpp * tests one potential prime entered by user * does not employ user-defined function * does not employ eof-controlled loop to test multiple primes * */ #include //for cout using namespace std; int main(){ int n, //potential prime entered by user pd = 2; //potential divisor //prompt and read n cout << "enter n > 1: "; cin >> n; //generate and test divisors while(n % pd != 0) pd++; //display result if (n == pd) cout << n << " is prime " << endl; else cout << n << " is composite " << endl; //exit cout << endl << "Exiting..." << endl; return 0; }