LogFAQs > #910493385

LurkerFAQs, Active DB, DB1, DB2, DB3, Database 4 ( 07.23.2018-12.31.2018 ), DB5, DB6, DB7, DB8, DB9, DB10, DB11, DB12, Clear
Topic List
Page List: 1
TopicCan 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