3.2k views

Consider a multidimensional array a[w][x][y][z].

In this array, a[i] gives address of a[i] and a[i]+j gives the address of a[i][j]

Similarly, a[i][j] gives address of a[i][j] and a[i][j]+k gives the address of a[i][j][k]

Hence a[i][j][k][l] can be accessed using pointers as *(a[i][j][k]+l)

where * stands for value at address and a[i][j][k]+l gives the address location of a[i][j][k][l].

Program: Example program to illustrate pointer denotation of multi-dimensional arrays.

#include<stdio.h>

#include<string.h>

int main() {

int a;

//it gives address of a .

printf(" \n address of array a is %u", a);

printf("\n address of a is %u ,given by a, %u given by a+2",

a, a + 2);

printf("\n address of a is %u ,given by a, %u given by a+2",

a, a + 2);

printf("\n address of a is %u ,given by a , %u given by a+1",

a, a + 1);

return 0;

}

Output:

address of array a is 65340

address of a is 65448, given by a , 65448 given by a+2

address of a is 65484, given by a ,65484 given by a+2

address of a is 65490, given by a , 65490 given by a+1

Explanation:

This output may differ from computer to computer as the address locations are not same for every computer.
answered by Guru (39.1k points) 10 22 36