+ 1
if(1<2&&2>1) is it true or false?
The above question asked while online viva it's true but teacher said it's false. He said you should think about it again, i didn't get what he actually want to say, if someone understand, please help
3 odpowiedzi
+ 4
Its definitely true.
Because 1<2 is true.
And 2>1 is also true
So true && true is true.
Ask your teacher to explain this 😂😂😂
You will feel proud on yourself that u are correct
+ 1
The answer is true not false.
1 < 2 = true
2 > 1 = true
Boolean algebra
(0 = false, 1 = true)
AND
0 0 -> 0
0 1 -> 0
1 0 -> 0
1 1 -> 1
0
maybe your teacher think && has higher precedence.
so.
1<2&&2>1
1<(2&&2)>1
1<true>1
which is wrong, and probably throw an error. maybe C++ will still evaluate as false, but i bet it'll also at least give a warning.
see the answer before mine, to see the right reason why your answer is right