jeudi 29 octobre 2015

IF statement with logical OR

Maybe one of you young gentlemen or ladies can help me with something.

if(1 == 2 || 4)
{
cout<<"True";
}
else
{
cout<<"False";
}

This is how I read the above. If 1 is equal to 2 or 4, then print true. Otherwise, print false. When this is executed though... true is printed. Obviously I'm misunderstanding something here. 1 is not equal to 2 or 4. Wouldn't that make it false?

Thank you and sorry for the stupid question.

Aucun commentaire:

Enregistrer un commentaire