Guess The Output series 6

Explanation of guess the output questions posted on our Instagram Page.
Click here to view Guess The Output series 5.


1) Guess the output

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 (&&).
It(&&) returns true if both operands are true otherwise it returns false.

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.
 https://www.instagram.com/computer_science_engineering_/


Click here to view Guess The Output series 5.


Admin

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top