...
GATE 2001
October 16, 2023
GATE 2002
October 16, 2023
GATE 2001
October 16, 2023
GATE 2002
October 16, 2023

Arrays

Question 4

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

          char a[100][100];    

Assuming that the main memory is byte-addressable and that the array is stored starting from memory address 0, the address of a [40][50] is:

A
4040
B
4050
C
5040
D
5050
Question 4 Explanation: 
Address for a[40][50] = BaseAddress + [40 * 100 * element size] + [50 * element size]
= 0 + [40 * 100 * 1] + [50 * 1]
= 4000 + 50
= 4050

Correct Answer: B
Question 4 Explanation: 
Address for a[40][50] = BaseAddress + [40 * 100 * element size] + [50 * element size]
= 0 + [40 * 100 * 1] + [50 * 1]
= 4000 + 50
= 4050

Leave a Reply

Your email address will not be published. Required fields are marked *