A three dimensional array in C++ is declared as int A [a] [b] [c]. Consider that array elements are stored in row major order and indexing begin from 0. Here the address of an item at the location A [r] [s] [t] computed in terms of word length w of an integer is 

This question was previously asked in
UGC NET Computer Science (Paper 2) 17 June 2023 Official Paper
View all UGC NET Papers >
  1. & A [0] [0] [0] + w (b*c*s + c*r + t) 
  2. & A [0] [0] [0] + w (b*c*r* + c*s + t) 
  3. & A [0] [0] [0] + w (a*b*r* + c*s + t)
  4. & A [0] [0] [0] + w (a*b*s + c*r + t)

Answer (Detailed Solution Below)

Option 2 : & A [0] [0] [0] + w (b*c*r* + c*s + t) 
Free
UGC NET Paper 1: Held on 21st August 2024 Shift 1
10.8 K Users
50 Questions 100 Marks 60 Mins

Detailed Solution

Download Solution PDF

The correct answer is & A [0] [0] [0] + w (b*c*r* + c*s + t)

EXPLANATION:

In C++, for a 3-dimensional array declared as int A[a][b][c], the memory is allocated in a sequence such that it increases with 'c' first, then 'b', and finally 'a'. This is because the elements are stored in row-major order.

  • So, when we are trying to find the address of an element A[r][s][t]:
    • 't' will contribute to its value directly, because we are moving in the 'c' dimension,
    • 's' will have to consider all 'c' steps we have to take for every shift in the 'b' direction, hence 's' contributes 'c*s' shifts,
    • 'r' will have to consider all 'bc' steps we have to take for every shift in the 'a' direction, hence 'r' contributes 'bc*r' shifts.

Therefore, the correct formula would be: & A[0][0][0] + w * (b*c*r + c*s + t)

So, the correct answer would be option 2: & A [0] [0] [0] + w (bcr + c*s + t)

Latest UGC NET Updates

Last updated on Jun 12, 2025

-> The UGC NET June 2025 exam will be conducted from 25th to 29th June 2025.

-> The UGC-NET exam takes place for 85 subjects, to determine the eligibility for 'Junior Research Fellowship’ and ‘Assistant Professor’ posts, as well as for PhD. admissions.

-> The exam is conducted bi-annually - in June and December cycles.

-> The exam comprises two papers - Paper I and Paper II. Paper I consists of 50 questions and Paper II consists of 100 questions. 

-> The candidates who are preparing for the exam can check the UGC NET Previous Year Papers and UGC NET Test Series to boost their preparations.

More OOPs concept Questions

Get Free Access Now
Hot Links: teen patti party teen patti master gold teen patti star apk teen patti refer earn teen patti real cash game