An array mat [20] [10] is stored in the memory along the row with each element occupying 4 bytes of memory. Find out the base address and the address of element mate[10][5] if the location of mat [3][7] is stored at the address 1000.
Answers
Answered by
1
row major formula= B+W[Nc(I-Lr)+(J-Lc)]
W=4
mat[3][7]=B+W[10(3-0)+(7-0)]
1000=B+4[30+7]
1000=B+148
B=1000-148
B=852
hence base address is 852
now address of mate[10][5]
mat[10][5]=852+4[10(10-0)+(5-0)]
=852+4[100+5]
=852+4*105
=852+420
mat[10][5]=1272
hence address of mat[10][5] is 1272
hope this helps
if u have any doubts or if there is any mistake in ans let me know in comments
Similar questions