Hey Fam,

I’m working on this ..so far this is what I have..(after almost 2 1/2 frustrated hours)

As a newbie, I figure out somehow the remainder and the prime concepts. I’m finally happy that I have 0 error but the program doesn’t do what I expected! Eventhough I tested w/t a prime number, a non-prime number, and an integer less than 2...

I’m struggling with my loop because I think the program performs the loop somewhere but doesn’t give the user the option to continue many times! where did I go wrong?

I’m attempted to use a do while loop for that. Will that works?

I think that I have use the % to find my remainder properly.

I also think that I have place my 2 integer variables num (use by the user) and div (to hold the remainder) in the right place..

As I put more effort to try to fix, the more problem I'm created and getting more confused. Any assistance is appreciated.

Thanks Eddy.

```
// This program allows the user to enter an integer greater than 1
// and tests to see if this integer is a prime number.
// This program also allows the user to do a few repetitions as possible.
#include <iostream>
using namespace std;
int main()
{
int num, div=2, result=0;
char answer;
// Get number from user
cout << " Enter a number: ";
cin >> num;
cout << " The number is " << num << endl;
if ( num <= 1 )
cout << "Please Enter another number: " <<endl;
return 0;
while ( div < num && num % div != 0 )
div++;
// number must be a prime
if ( div == num )
return 1;
else
// number is not a prime
return 0;
{
if (num % div == 0)
cout << div << " is a factor of " << num << endl;
result++;
if (result == 1)
cout << "The number " << num <<" is a prime\n";
else
cout << "The number " << num <<" is not a prime\n";
return 0;
}
do
{
cout << "Do you want to continue?(Enter Yes or No)"<<endl;
cin >> answer;
num=answer;
}
while (answer != 'n' && answer !='N');
return 0;
}
```