Skip to content
Question of 97

Q.Let us assume P[20][10] is a two-dimensional array, which is stored in the memory along the row with each of its elements occupying 2 bytes, find the address of the element P[10][5], if the address of the element P[5][2] is 25000.

(OR)
Let us assume P[20][30] is a two-dimensional array, which is stored in the memory along the column with each of its elements occupying 2 bytes. Find the address of the element P[5][6], if the base address of the array is 25000.
CBSECBSE Class XII Board 2019Subjective· 3mImportance★★★★★est
0% · 0/97 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

Part (a): using row-major addressing, P[10][5] is at 25106 (given P[5][2]=25000). Part (b): using column-major addressing with base 25000, P[5][6] is at 25250.

Part (a)

For an array P[R][C] stored row-major (along the row) with word size W:

Address(P[i][j])=Base+(i⋅C+j)⋅WAddress(P[i][j]) = Base + (i \cdot C + j)\cdot W

Here C = 10 (columns), W = 2. We are given Address(P[5][2]) = 25000 and want Address(P[10][5]). It is easiest to take the difference so the unknown base cancels:

  • linear index of P[10][5] = 10·10 + 5 = 105
  • linear index of P[5][2] = 5·10 + 2 = 52
  • offset = (105 − 52)·2 = 53·2 = 106 bytes

Address(P[10][5])=25000+106=25106Address(P[10][5]) = 25000 + 106 = 25106 …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.