Array address calculation 2012

A matrix B[10][7] is stored in the memory with each requiring 2 bytes of storage. If the base address at B[x][1] is 1012 and the address at B[7][3] is 1060 determine the value of ‘x’ where the matrix is stored in Column Major wise
Given i=10, j=7, w=2, B =1012 r=10, w=?
Add[i][j] = 1060
Column wise
Add[i][j] = B + [(j=Lc)+(i-Lr)]
1060 = 1012 + [(3-1) * 10 +(7-x)] *2
1060 -1012 =2[(7-x) +20]
48=2[(7-x) +20]
7-x = 4
x= 7-4 =3

This entry was posted in address. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *