Difficulty: Medium
Correct Answer: 8 2
Explanation:
Introduction / Context:
This problem tests short-circuit OR (||) behavior with pre-increment. With OR, once the left operand is true, the right operand is not evaluated.
Given Data / Assumptions:
Concept / Approach:
For ||, if the left-hand side becomes true, the right-hand side is skipped (no ++y). Therefore ++y happens only while (++x > 2) is still false.
Step-by-Step Solution:
Verification / Alternative check:
Instrument the loop with prints for x and y on each iteration to validate the sequence.
Why Other Options Are Wrong:
They assume y keeps increasing after left-hand side becomes true, ignoring short-circuit OR.
Common Pitfalls:
Not realizing that once (++x > 2) becomes true, (++y > 2) never executes again in later iterations.
Final Answer:
8 2
Discussion & Comments