Consider the following declaration of a ‘two-dimensional array in C:
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 (GATE CS 2002)
(A) 4040
(B) 4050
(C) 5040
(D) 5050
Answer: (B)
Explanation:
Address of a[40][50] = Base address + 40*100*element_size + 50*element_size
= 0 + 4000*1 + 50*1
= 4050
Based on row major or column major
if row major then the result will be 4050
if column major then
Address of a[40][50] = Base address + 50*100*element_size + 40*element_size
= 0 + 5000*1 + 40*1
= 5040
Quiz of this Question
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
03 Aug, 2018
Like Article
Save Article