hey i need to find out how to do this..

stopping a program when the number entered is zero my main says:

cout << "Enter a number to test for primality, or zero to exit ->: ";



soo im not sure exactly how to do this normaly i would close it like this:


cout << "Press ENTER to finish...";
cin.ignore(99,'\n');
return 0;
}
cout << "Enter a number to test for primality, or zero to exit ->: ";

You need to get the user number.
1
2
3
4
int n=0;//declare n and initialize to 0
cin>>n//get the number
if(n=0)return 0;//OR
if(n=0)exit;

You need some instruction to keep the screen open until you read it like:
char c;
cin.get(c);
@bufbill: your if statements are assignments not comparisons.
Topic archived. No new replies allowed.