Difficulty: Medium
Correct Answer: 65480, 65496
Explanation:
Introduction / Context:
This C pointer-arithmetic question checks how array types decay to pointers and how pointer increments depend on the pointed-to type size. It specifically contrasts a+1 (pointer to the next row) with &a+1 (pointer to the next whole array) on a 16-bit-style assumption where int is 2 bytes and the array base address is fixed for calculation.
Given Data / Assumptions:
Concept / Approach:
In expressions, a (array) decays to pointer-to-first-row of type int (*)[4]. Incrementing such a pointer advances by sizeof(one row) = 4 * sizeof(int). For &a, the type is pointer to the entire array, int (*)[3][4]. Incrementing &a moves by sizeof(whole array) = 3 * 4 * sizeof(int).
Step-by-Step Solution:
Verification / Alternative check:
Visualize memory as 3 contiguous rows of 8 bytes each. Moving one row forward adds 8; moving one entire 3x4 block forward adds 24. The arithmetic matches this picture.
Why Other Options Are Wrong:
Common Pitfalls:
Confusing a (pointer to row) with &a (pointer to whole array), and assuming +1 always adds 1 byte rather than sizeof(pointed-type).
Final Answer:
65480, 65496
Discussion & Comments