Feb 16, 2013 at 5:49pm
if (room != 1,2,3)
{
cout << "Invalid room type choice" << endl;
}
Is there any mistakes with my code? When I enter 1, the process continues but Invalid room type choice is still shown..
Please help me. Thank you so much.
Feb 16, 2013 at 6:04pm
1 2 3 4
|
if( room != 1 && room != 2 && room != 3 )
{
std::cout << "Invalid room type choice\n";
}
|
Or, in this case..
1 2 3 4
|
if( room < 1 || room > 3 )
{
std::cout << "Invalid room type choice\n";
}
|
Edit: Cheers,
Disch. Noob move... :-S
Last edited on Feb 16, 2013 at 6:12pm
Feb 16, 2013 at 6:11pm
iHutch's first example was backwards. It should be && instead of ||
using || will result in it always being true.
Feb 18, 2013 at 2:21pm
It worked! Thank you so much! :)