Data Structure

Question

T[25][30] is a two dimensional array, which is stored in the memory along the row with each of its element occupying 2 bytes, find the address of the element T[10][15], if the element T[5][10] is stored at the memory location 25000.

Answer

LOC(T[10][15]) = LOC(T[5][10]) + 2(30*(10-5) + (15-10))
                       = 25000 + 2(150 + 5)
                       = 25000 + 2(155)
                       = 25000 + 310
                       = 25310

Sponsor Area