An integer array a [30][40] is stored along the column in the memory. If the element a[20][25] is stored at 50000, find out the location of a[25][30].
Answers
Answered by
1
Total number of rows= 30
Total size= 2 bytes
Base Address= 26500
LOC (P[I][J]) = BaseAddress+((I-LBR) + (J-LBC) * R)*W
Assuming Lower Bound of Row(LBR)=0
Lower Bound of Column(LBC)=0
Total number of Rows(R)=30
Size of each element(W)=2
LOC(P[20][10])= 26500 +((20-0)+(10-0)*30)*2
LOC(P[20][10])= 26500 +640
LOC(P[20][10])= 27140
Similar questions