Saturday, 25 February 2017

GATE EXAM PREPARATION IN "C" - (GATE CS 2002)

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
Answer(b)

Address of a[40][50] = 
     Base address + 40*100*element_size + 50*element_size
     0 + 4000*1 + 50*1
     4050

No comments:

Post a Comment