Awesome q2a theme
0 votes
10 views

Consider the following declaration of a two – dimensional array in C

char a[50][50];

Assuming that the main memory is byte – addressable and that the array is stored starting from memory address $0$, the address of $a[20][25]$ is:

  1. $2020$
  2. $2525$
  3. $2025$
  4. $2050$
in Others by (178 points)
edited by | 10 views

1 Answer

0 votes

Assuming it to be Row major and the array index starts from 0 and size of int is 2 Bytes, we can solve it as

A[i][j]= base + {i*d2 +j}* (size of int in bytes) ………………… [where A[50][50] = A[d1][d2], so d1= 50, d2=50]

A[20][25] = 0+ {20*50 +25}*2

                =2050

by (1.3k points)
932 questions
596 answers
1,885 comments
81,474 users