+ 2
How is the output 84
Int x = 7, y=4; If(++x > 6 || ++ y <5) Cout<<x<<y; else Cout<<x*y;
5 odpowiedzi
+ 7
x = 7
So the evaluation for `++x > 6` yields true, and simultaneously increased value of <x> to become 8. Logical OR operator returns and yet doesn't check successive operands when the first one evaluates to true, that's why `++y < 5` is not getting executed (value of <y> remains to be 4).
Because `++x > 6` evaluates to true, the `if` statement executed the `if` block rather than the `else` block.
Hth, cmiiw
+ 5
This is called short circuiting, where successive operands are not checked when the result of the OR is already true.
+ 4
You're welcome 👍
+ 1
Thanks
+ 1
++x = 8 ++y = 5 answer 84 (concat output) 🤔