We need it to say if the number is prime or not we need the equation for the if statement or if we have something else wrong to let me know.

#include <iostream>

using namespace std;

int main ()

{

int number;

bool countr;

for (countr = 0; countr <= 2; countr ++)

{cout << " Enter a number to determine whether it is prime: " ;

cin >> number;

cout << endl;

if ()

{cout << number << " is prime " <<endl;

cout << endl;}

else

{cout << number << " is NOT prime " <<endl;

cout << endl;}

}

cin.ignore (10);

return 0;

}

#include <iostream>

using namespace std;

int main ()

{

int number;

bool countr;

for (countr = 0; countr <= 2; countr ++)

{cout << " Enter a number to determine whether it is prime: " ;

cin >> number;

cout << endl;

if ()

{cout << number << " is prime " <<endl;

cout << endl;}

else

{cout << number << " is NOT prime " <<endl;

cout << endl;}

}

cin.ignore (10);

return 0;

}

Duplicate (maimed) thread here:

http://www.cplusplus.com/forum/general/112468/

Are you ignoring my other reply?

Do the research!

Or if you're that lazy, here's a generous hint: a number is prime if the only numbers it divides exactly to (that means no remainder) are 1 and itself.

0 prime? no (divides with zero remainder to everything except itself and infinities)

1 prime? no (only divides to itself)

2**yes** 1,2

3**yes** 1,3

4 no, 1,2,4

5**yes** 1,5

6 no 1,2,3,6

7**yes** 1,7

8 no 1,2,4,8

9 no 1,3,9

10 no 1,2,5,10

11**yes** 1,11

http://www.cplusplus.com/forum/general/112468/

Are you ignoring my other reply?

Do the research!

Or if you're that lazy, here's a generous hint: a number is prime if the only numbers it divides exactly to (that means no remainder) are 1 and itself.

0 prime? no (divides with zero remainder to everything except itself and infinities)

1 prime? no (only divides to itself)

2

3

4 no, 1,2,4

5

6 no 1,2,3,6

7

8 no 1,2,4,8

9 no 1,3,9

10 no 1,2,5,10

11

Last edited on

Topic archived. No new replies allowed.