MCQ Hive stays free thanks to ads. Please disable your ad blocker for this site so content and features keep working.
Data Types
Arrays & Memory Layout
Beginner
Q
For int a[3][4] stored in row-major order at base address 1000, with 4-byte ints, what is the address of a[2][1]?
A1044
B1036
C1024
D1028
Correct Answer:
B. 1036
Explanation:
base + (i × cols + j) × size = 1000 + (2×4 + 1) × 4 = 1036.
ALSO KNOW (related points):
• In which order does C/C++ store multidimensional arrays? → Row-major order
• How is a Python list implemented in CPython? → As a dynamic array of references, with amortized O(1) append