104 views

Answer is 407 , how? Please dont just throw away formula, explain it.

No formula used.

This requires just counting of numbers.See the below diagram

Each element requires 2B.

Like A[0][0] =351-352 ,A[0][1]=353-354.......

This is given to have a idea on how elements are stored and not beneficial when in big size is given.

selected
Given array is Table[6][8] means the dimension of the 2D array is 6 rows * 8 columns

Desired location of table[3][4] means a element which is available in 4th row .

and in 4th row it is present at 5th coulmn .

so for reaching the 4th row , you have to cross the all elements present in 3 rows so = 3*8(bcoz 8 element will be present in one row )

and in 4th row for reaching the 5th column element you have to cross the previous 4 element present in 4th row .

so element need to be cross in 4th row =4

so total element need to be crossed = 3*8+4 =28 elements

consider size of int is 2 bytes . so bytes need to skipped = 28*2 =56 bytes

as given base address of 2D array is 351 . so from 351 we need to move 56 bytes ahead = 351+56 =407

so 407 is the address of table[3][4] .
we have to find TABLE[3][4]

according to given data number of columns in array=8

Number of rows before TABLE[3][4] = 3 ( 0th row, 1st row, 2nd row )

so elements in this 3 rows = 3 * 8 = 24

now number of columns before TABLE[3][4] = 4 ( 0,1,2,3 )

so total elements before TABLE[3][4] = 24+4

So location = 351 + 28*2 =407. I have assumed size of int as 2 bytes