An array S[10] [30] is stored in the memory along the column with each of its element occupying 2 bytes. Find out the memory location of S[5][10], if element S[2][15] is stored at the location 8200.
Answers
Answered by
2
Here is your answer.
use the formula
address = B+W ((I-Lc)N+(J-Lr))
where B is base address
W is element size
Lc and Lr are lower and upper. bound of array
M and N are rows amd columns
Attachments:
Answered by
0
The memory location of S[5][10] is 8106
Given,
ASSUMING LBR=2
LBC=15
B = 8200
To Find
The memory location of S[5][10]
Solution
W=2 BYTES, NUMBER OF ROWS(M)=10, NUMBER OF COLUMNS(N)=30
LOC(S[I][J]) = B +((I-LBR) + (J-LBC)*M)*W
LOC(S[5][10])= 8200 + ((5-2) + (10-15)*10)*2
= 8200 + (3 + (-5)*10) * 2
= 8200 + (3 + (-50)) * 2
= 8200 + (3 – 50) * 2
= 8200 + (-47) * 2
= 8200 – 94
= 8106
Hence , the memory location of S[5][10] is 8106
#SPJ2
Similar questions
Math,
7 months ago
English,
7 months ago
Math,
7 months ago
Computer Science,
1 year ago
Biology,
1 year ago