Data-Structures
October 16, 2023Data-Structures
October 16, 2023Arrays
Question 4
|
Consider the following declaration of a two dimensional array in C:
char a[100][100];
Assuming that the main memory is byte-addressable and that the array is stored starting from memory address 0, the address of a [40][50] is:
4040
|
|
4050
|
|
5040
|
|
5050
|
Question 4 Explanation:
Address for a[40][50] = BaseAddress + [40 * 100 * element size] + [50 * element size]
= 0 + [40 * 100 * 1] + [50 * 1]
= 4000 + 50
= 4050
= 0 + [40 * 100 * 1] + [50 * 1]
= 4000 + 50
= 4050
Correct Answer: B
Question 4 Explanation:
Address for a[40][50] = BaseAddress + [40 * 100 * element size] + [50 * element size]
= 0 + [40 * 100 * 1] + [50 * 1]
= 4000 + 50
= 4050
= 0 + [40 * 100 * 1] + [50 * 1]
= 4000 + 50
= 4050
Subscribe
Login
0 Comments