+ 2
#include <iostream> using namespace std; int main() { int i; int a; bool isPrime = true; cout << "Enter a number: "; cin >> a; cout << a << " and is "; for(i = 2; i <= a / 2; ++i) { if(a % i == 0) { isPrime = false; break; } } if (isPrime) { cout << "a prime number"; } else { cout << "not a prime number"; } return 0; }
28th Mar 2017, 2:16 PM
Jarod C (Celestial)
Jarod C (Celestial) - avatar