Difficulty: Easy
Correct Answer: 8, 8, 8
Explanation:
Introduction / Context:
The exercise ensures you can trace multiple levels of indirection. The pointers p
, q
, and r
successively point to the location of i
, the location of p
, and the location of q
. Dereferencing the correct number of times should always yield the integer value stored in i
.
Given Data / Assumptions:
Concept / Approach:
At each level, dereference once to move toward the underlying object. The star count must match the pointer depth: one star for p
, two for q
, three for r
. All evaluate to the same stored scalar.
Step-by-Step Solution:
*p = i = 8**q = ((&i)) = *(&i) = i = 8**r = **((&p)) = **(&p) = *p = i = 8
Verification / Alternative check:
Temporarily print addresses to confirm the chain: &i == p&p == q&q == r and match the dereference counts.
Why Other Options Are Wrong:
(b)–(d) list pretend addresses instead of values. The code prints integers obtained by dereferencing, not addresses.
Common Pitfalls:
Confusing the number of dereferences; printing pointers rather than values; assuming pointer size affects the printed values here.
Final Answer:
8, 8, 8
Discussion & Comments