Topic List | Page List: 1 |
---|---|
Topic | Can anyone help me with this c++ program? |
OhhhJa 10/14/18 1:10:29 AM #1: | #include <iostream> using namespace std; int Prime(int); void primes (int n); int main() { int n; cout << "Enter a positive integer: "; cin >> n; while (n >= 0) { if(Prime(n) == 0) cout << n << " is a prime number."; else cout << n << " is not a prime number."; return 0; } } int Prime(int n) { bool flag = false; for(int i = 2; i <= n/2; ++i) { if(n%i == 0) { flag = true; break; } } return flag; } How would I adjust this program to make it print out all prime numbers up to n = 12? I'll give you the best blowie of your life if you help ... Copied to Clipboard! |
Topic List | Page List: 1 |