0

This has me a bit stumped but I must be doing something wrong here, if you don't mind checking this for me would be greatly appreciated.

int main ()
{
	int input;

		cout << "Enter a positive intiger to determin if it is odd or even (-1 to cancel): "; 
		cin >> input; 

	if ( input != -1) 
	{
 		cout << "Thank you please close the program./n"; 
	}
	else if  (input%2 == 0) 
	{ 
		cout << "The number is Even./n"; 
	}

	else
	{
		cout << "The Number is Odd./n"; 
	}

return 0; 
}
3
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by VernonDozier
0

Well you need a loop if you want to keep asking the user for input until they enter -1.

{
  bool done = false;

  while (!done){
    // ask for input and do my processing 
   
    // when input is -1, set done to true and exit. 
    done = true;

  }
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.