How would I write that to make it work?
while (choice !=(0)||(1)||(2)||(3)) {cout<< "Try again "; cin>> choice;}
Printable View
How would I write that to make it work?
while (choice !=(0)||(1)||(2)||(3)) {cout<< "Try again "; cin>> choice;}
((choice!=0) && (choice!=1)&&(choice!=2)&&(choice!=3))
Z.
why not
choice>3||choice<0
Do I have to rewrite choice every time? Is there any way around doing that?
And I didn't want to use the < > becuase that does not work for characters.
You have to rewrite choice each time.Quote:
Originally posted by aewarnick
Do I have to rewrite choice every time? Is there any way around doing that?
And I didn't want to use the < > becuase that does not work for characters.
And < > both work with characters.
Z.
Do you mean that C++ follows the alphabet?
C++ knows that 'A' comes before 'B', if that is what you are asking.Quote:
Originally posted by aewarnick
Do you mean that C++ follows the alphabet?
Z.
But 'a' comes after 'Z', so it doesn't work every time.
Great! Thank you.
But of course... 'Z' is a much better letter :DQuote:
Originally posted by CornedBee
But 'a' comes after 'Z', so it doesn't work every time.
Z.
assuming choice is an alpha you could flag off the lower case bit
choice&0xdf<'C'
Hehe, sure.. You can also do choice &= 3; in the original question and then not worry about an invalid choice ;)Quote:
Originally posted by kedaman
assuming choice is an alpha you could flag off the lower case bit
choice&0xdf<'C'
hehe how about this for the test ;)
choice&0xFFFFFFFC