Difficulty: Medium
Correct Answer: -2, 3, 0, 1
Explanation:
Introduction / Context:
This problem blends operator precedence (&& before ||), short-circuit evaluation, and side effects of the pre-increment operator. Mastering the order of evaluation and when increments occur is essential for correct reasoning about C expressions.
Given Data / Assumptions:
Concept / Approach:
Evaluate ++i, then ++j only if needed by &&, and ++k only if the left side of || is false. Nonzero values count as true. Carefully track variable updates as you go.
Step-by-Step Solution:
Verification / Alternative check:
Insert prints after each step or separate the expression into temporaries to see the same final state, confirming short-circuit behavior prevents ++k from executing.
Why Other Options Are Wrong:
Common Pitfalls:
Forgetting precedence and imagining left-to-right increments without considering short-circuit; assuming negative values are false (they are true if nonzero).
Final Answer:
-2, 3, 0, 1.
Discussion & Comments