MENU
Question -

An array T[-1..35][-2..15] is stored in the memory along the row with each element occupying 4 bytes. Find out the base address and address of element T[20][5], if an element T[2][2] is stored at the memory location 3000. Find the total number of elements stored in T and number of bytes allocated to T.



Answer -

Take T[2][2] as the base address [BA],
sr=starting row, sc=starting column;
Along the row
A[i][j] = BA + size[nc*(i-sr) + (j-sc)]
T[20][5] = 3000 + 4 [ 18 * (20-2) + (5-2)]
= 3000 + 4[(18 * 18) + (3)]
= 3000 + 4[324 + 3]
= 3000 + 4(327)
= 3000 + 1308
= 4308
nc = no. of columns sr=2 sc=2
Total number of elements stored in T=37*18=666
Total number of bytes allocated to T=666*4=2664

Comment(S)

Show all Coment

Leave a Comment

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