Difficulty: Easy
Correct Answer: k, k
Explanation:
Introduction / Context:
This question reinforces that array indexing and equivalent pointer arithmetic produce the same result. With an array of strings (2D char array), both expressions select the same character from the third string.
Given Data / Assumptions:
Concept / Approach:
For any array a, a[i] ≡ (a + i). Therefore, mess[2] (a char[30]) decays to a char pointing to the first character of the third string. Adding 9 moves to the 10th character; dereferencing yields that character. The pointer-form ((mess + 2) + 9) is the same computation spelled out explicitly.
Step-by-Step Solution:
Row 2 string: "Don't walk behind me...".Indexing characters (0-based): D(0) o(1) n(2) '(3) t(4) (space 5) w(6) a(7) l(8) k(9).Both expressions select index 9 → 'k'.printf prints: k, k.
Verification / Alternative check:
Replace the first with mess[2][9] and the second with *(&mess[2][0] + 9); both still refer to the same element.
Why Other Options Are Wrong:
(a), (c), and (d) pick other letters; (e) is incorrect since all indexing is within bounds.
Common Pitfalls:
Miscounting indexes due to spaces and punctuation; forgetting zero-based indexing.
Final Answer:
k, k
Discussion & Comments