All Exams Test series for 1 year @ ₹349 only
Question

A three dimensional array in ‘C’ is declared as int A[x][y][z]. Here, the address of an item at the location A[p][q][r] can be computed as follows (where w is the word length of an integer) :

This question was previously asked in
UGC NET 2015 Paper 1 Question Paper (27-Dec-2015)
The correct answer is

&A[0][0][0] + w(y*z*p + z*q + r)

C stores arrays in row-major order, so the last index varies fastest.

Each value of the first index skips a full y by z plane: \(p \times (y \times z)\) elements.

Each value of the second index skips a row of z elements: \(q \times z\) elements, and the last index adds r elements.

Offset \(= y z p + z q + r\) elements, so address \(= \&A[0][0][0] + w(yzp + zq + r)\)

Check: A[0][0][1] lies w bytes after the base and A[0][1][0] lies zw bytes after it, which only this formula gives.

Hence, &A[0][0][0] + w(y*z*p + z*q + r).

Was this answer helpful?

Similar Questions

  1. When we pass an array as an argument to a function, what actually gets passed ?

  2. Given

    int arr[3][4][2]= {{{2,4},{7,8},{3,4},{5,6}},{{7,6},{3,4},{5,3},{2,3}},{{8.9},{7,2},{3,4},{5,1}}};

    Which one of the following can be used to refer to element 1 in the above 3-d array?

  3. Which of the following is true for computation time in insertion, deletion and finding maximum and minimum element in a sorted array ?

  4. Consider an array A[20, 10], assume 4 words per memory cell and the base address of array A is 100. What is the address of A[11, 5] ? Assume row major storage.

  5. When an array is passed as parameter to a function, which of the following statements is correct ?


Important Questions from Array

  1. Consider the following C program segment.

    #include <stdio.h>

    int main()
    {
      char s1[7] = "1234";
        char *p;

        p = s1 + 2;
        *p = '0';

        printf("%s", s1);

        return 0;
    }

    What will be printed by the program?
  2. #include <stdio.h>
    
    void foo(int *p, int x){
        *p = x;
    }
    
    int main(){
        int *z;
        int a = 20, b = 25;
        z = &a;
        foo(z, b);
        printf("%d", a);
        return 0;
    }
    
    The output of the given C program is __________. (Answer in integer)
  3. Consider an array $A$ of integers of size $n$. The indices of $A$ run from 1 to $n$. An algorithm is to be designed to check whether $A$ satisfies the condition given below.

    $\forall i,j \in \{1, \dots, n-1\}$ such that $i > j$, $(A[i + 1] - A[i]) > (A[j + 1] - A[j])$

    Which one of the following gives the worst case time complexity of the fastest algorithm that can be designed for the problem?
  4. What is the output the given C language code snippet? 

    #include<stdio.h>

     int main()

    {

     int x[] = {10,20,30}; 

    int *p = x; 

    p++; 

    printf("%d",*p); 

    return 0; 

    }

  5. Which of the following expression will delete the entire array pointed to by q?

Need Expert Advice?
Upcoming Exams
CTET
December 12, 2026
Test Series
UGC NET img
Teaching
UGC NET (Paper 2) 2026 Mock Test Series
796 Tests 2 Tests Free
4.4(39)
English
More Questions from UGC NET

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App