the code below runs but i dont know how to modify the else-if statement..
the statement..
look at the underlined text below..
the program just proceeds..
if you enter "y" the program returns to main then executes the else statement(error!only enter letters 'y' or 'n'!the program will now end)..
help please?
can anyone?
thanks
'or' in C++ is written '||'. Also, it's if(statement || statement), not if (a == 'y' || 'Y'). The latter will always be true, because it basically says if('Y') which is always true since 'Y' isn't 0.
int main( )
{
while( true )
{
std::cout << "Memory game" << std::endl;
int input( 0 );
std::cout << "Enter a number. Any number, except zero: ";
std::cin >> input;
if( input == 0 )
{
std::cout << "That's not an acceptable number" << std::endl;
// Go back to the start of this loop.
continue;
}
// Continue with the game...
}
return 0;
}