MENU
Question -

An array P[30][20] is stored along the column in the memory with each element requiring 2 bytes of storage. If the base address of the array P is 26500, find out the location of P[20][10].



Answer -

Total number of rows = 30
Total size = 2 bytes
Base Address = 26500
LOC(P[I][J]) = Base Address+((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

Comment(S)

Show all Coment

Leave a Comment

Free - Previous Years Question Papers
Any questions? Ask us!
×