Line 16: You want the && condition, not ||.
If choice is 2, then choice!=1 is true and your loop continues.
Likewise if choice is 1, then choice!=2 is true and your loop continues.
Last edited on
But if i type
int x;
do
{
std::cout << "Type 1 or 2 to exit the loop";
}
while (x != 1 && x != 2)
If the user type '1' will be true but for 2 no, so the loop continue ?
EDIT:
I mean :
The compiler : ok, while x is not egal to 1 or x is not egal to 2, i continue my loop but if x is egal to 1 or 2 i go out the loop !
Last edited on
Yeah ! Thanks !
But logycally, it is the same thing as while (x != 1 || x != 2) no ? :\
No.
The order of evaluation makes a difference.
Ok! Thanks for your time AbstactionAnon :)