Help with !

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.
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
iHutch's first example was backwards. It should be && instead of ||
using || will result in it always being true.
It worked! Thank you so much! :)
Topic archived. No new replies allowed.