Share

# Arr[15] Ft:20] is a Two-dimensional Array, Which is Stored in the Memory Along the Row with Each of Its Elements Occupying 4 .Bytes. Find the .Address of the Element Arr[5)[15], If the Element Arr[Lo] [5] is Stored at the Memory Location 35000. - CBSE (Science) Class 12 - Computer Science (C++)

ConceptOne and Two Dimensional Arrays - Sequential Allocation and Address Calculation

#### Question

ARR[15] ft:20] is a two-dimensional array, which is stored in the memory along the row with each of its elements occupying 4 .bytes. Find the .address of the element ARR[5)[15], if the element ARR[lO] [5] is stored at the memory location 35000.

#### Solution

Given:

Arr[15][20]

W = 4  B = ?  Lr = 0  Lc = 0  R = 15 C = 20

Address of an element (I,J) in row major = B + W(C(I - Lr) + (J - Lc))

Therefore 35000 = B + 4(20(10 - 0) + (5 - 0))

= B + 4(20 x 10 + 5)

= B + 4(200 + 5)

= B + 4 x 205

= B + 820

B = 34180

Address of Arr[5][15] = 34180 + 4(20 x 5 + 15)

= 34180 + 4(100 + 15)

= 34180 + 4 x 115

= 34180 + 460

= 34640

Is there an error in this question or solution?

#### APPEARS IN

Solution Arr[15] Ft:20] is a Two-dimensional Array, Which is Stored in the Memory Along the Row with Each of Its Elements Occupying 4 .Bytes. Find the .Address of the Element Arr[5)[15], If the Element Arr[Lo] [5] is Stored at the Memory Location 35000. Concept: One and Two Dimensional Arrays - Sequential Allocation and Address Calculation.
S