1) Guess the output
Output of above C Program is A) 0 10.
The final value of integer variable z is 0 and variable x is 10.
Why 🤔 ?
Let’s understand logical AND operator (&&).
true if both operands are
true otherwise it returns
Initially, first operand is completely evaluated and if first operand evaluates to true i.e.(non-zero) then and then second operand will be evaluated.
In this case, the first operand is x>y and second operand is x++.
Result of first operand(x>y) is zero because value of x is 10 and y is 20. 10>20 is false.
So the second operand (x++) will not be evaluated and value of x remains same.
The result of x>y && x++ is assigned to integer variable z and which is 0(false).
Finally value of z is 0 and x is 10 so the output of above C Program is A) 0 10.
Click on Execute button to Run above code:
For more programming related questions and fun,
Follow us on Instagram.
Click here to view Guess The Output series 5.