Difficulty: Medium
Correct Answer: The program will print the output 10 11 11.
Explanation:
Introduction / Context: This exercise ties together constructor side effects on globals, a Display call inside the constructor, and later reference-based increments/decrements printed in main. You must include the constructor’s output (printed before main’s cout values) in the final sequence.
Given Data / Assumptions:
Concept / Approach: Process prints chronologically: first the constructor’s Display, then the cout line in main. Carefully apply pre/post increment semantics to s (alias of i) and z (alias of j).
Step-by-Step Solution:
Constructor: i=10, j=10; Display() prints "10 ". Then i++ makes i=11. s-- prints 11 (old i), then i becomes 10. ++z increments j from 10 to 11 and prints 11. Combined output: "10 11 11".Verification / Alternative check: Manually substitute i and j in the final cout to confirm the values at each stage.
Why Other Options Are Wrong: They either add an extra number, miss the constructor print, or misuse pre/post rules.
Common Pitfalls: Forgetting that s-- prints the old value and that Display already printed once from the constructor.
Final Answer: The program will print the output 10 11 11.
Discussion & Comments