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; 
}

Recommended Answers

All 2 Replies

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;

  }

It's a little ambiguous what the problem is. Do you want to repeat till a -1 is entered? If so, see stilllearning's post. If the problem is that your console closes too fast to see the output and you want to keep the console open, see this thread:

http://www.dreamincode.net/forums/showtopic30581.htm

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.