+ 2

Int x=2,y=2; if(++x>2 && y-->2)

Why this condition is false

15th Oct 2021, 3:13 PM
AK 47
3 Answers
+ 2
Because 2 > 2 is false so (true && false) will be false
15th Oct 2021, 3:13 PM
A͢J
A͢J - avatar
+ 2
Also, logical AND operator will evaluate the RHS operand when the LHS operand evaluates to true. So here, both `++x > 2` and `y-- > 2` are evaluated. This will not be the case when the LHS operand evaluates to false, as per the short circuit evaluation definition.
15th Oct 2021, 3:23 PM
Ipang
0
(++x>2 && y-->2) Evaluates to (3>2 && 2>2) Then (True && False) And finally reduces to (False)
15th Oct 2021, 5:26 PM
Brian
Brian - avatar