...
Operating-Systems
October 11, 2023
Process-Scheduling
October 11, 2023
Operating-Systems
October 11, 2023
Process-Scheduling
October 11, 2023

Arrays

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]?

A
15i + j + 84
B
15j + i + 84
C
10i + j + 89
D
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
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
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
error: Alert: Content selection is disabled!!