Operating-Systems
October 11, 2023Process-Scheduling
October 11, 2023Arrays
Question 2 |
Let A be a two dimensional array declared as follows:
A: array [1 ... 10] [1 ... 15] of integer;
Assuming that each integer takes one memory location, the array is stored in row-major order and the first element of the array is stored at location 100, what is the address of the element a[i][j]?
15i + j + 84 | |
15j + i + 84 | |
10i + j + 89 | |
10j + i + 89 |
Question 2 Explanation:
The address of element A[i][j] will be,
100 + 15 * (i-1) + (j-1)
= 100 + 15i – 15 + j – 1
= 15i + j + 84
100 + 15 * (i-1) + (j-1)
= 100 + 15i – 15 + j – 1
= 15i + j + 84
Correct Answer: A
Question 2 Explanation:
The address of element A[i][j] will be,
100 + 15 * (i-1) + (j-1)
= 100 + 15i – 15 + j – 1
= 15i + j + 84
100 + 15 * (i-1) + (j-1)
= 100 + 15i – 15 + j – 1
= 15i + j + 84
Subscribe
Login
0 Comments