+3 votes
in Class 12 by kratos

An array VAL[1..15][1..10] is stored I the memory with each element requiring 4 bytes of storage. If the base address of array VAL is 1500, determine the location of VAL[12][9] when the array VAL is stored (i) Row wise (ii) Column wise.

1 Answer

+4 votes
by kratos
 
Best answer

Base address B=1500

Element width w=4 bytes

Total rows r=15

Total columns c=10

ARR[I][J] = ARR[12][9]

=> I = 12, J = 9

Lowest row index lr= 0 in C++

Lowest column index lc= 0 in C++

(i) Row wise

VAL[I][J] = B + w(c(I – lr) + (J – Lc)

VAL[12][9] = 1500 + 4(10(12-1) + (9-1))

= 1500 + 472

= 1972

(ii) Column wise

VAL[I][J]=B+W(I-lr)+R(J-lc)

= 1500+4((12-1)+15(9-1))

= 1500+4(131)

= 1500+524

= 2024

...