Difficulty: Medium
Correct Answer: 3, 2, 15
Explanation:
Introduction / Context: This question targets operator side effects: pre-increment (++x) vs post-increment (x++), and how these changes alter subsequent indexing into an array.
Given Data / Assumptions:
Concept / Approach: Pre-increment changes the variable then yields the incremented value. Post-increment yields the current value, then increments it. Also, using i++ as an index uses the old i for access and increments afterward.
Step-by-Step Solution:
Start: a[1] = 1 i = ++a[1] -> a[1] becomes 2, i = 2 j = a[1]++ -> j = 2, then a[1] becomes 3 m = a[i++] -> use i=2 to index: m = a[2] = 15, then i becomes 3 Final: i=3, j=2, m=15Verification / Alternative check: Trace with a quick table of i and a[1] across each statement; results remain consistent with pre/post rules.
Why Other Options Are Wrong:
Common Pitfalls: Forgetting that i++ uses the old i for indexing before incrementing, and mixing up pre vs post effects on a[1].
Final Answer: 3, 2, 15
Discussion & Comments