Developer community
0 votes
asked by Expert (13.2k points) 27 43 61 | 3.2k views

1 Answer

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

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

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

a[i][j][k] gives address of a[i][j][k][0] and a[i][j][k]+l gives address of a[i][j][k][l]

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.



int main() {

int a[3][3][3][3];

//it gives address of a[0][0][0][0] .

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

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

a[2], a + 2);

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

a[2][2], a[2] + 2);

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

a[2][2][1], a[2][2] + 1);

return 0;



address of array a is 65340

address of a[2][0][0][0] is 65448, given by a[2] , 65448 given by a+2

address of a[2][2][0][0] is 65484, given by a[2][2] ,65484 given by a[2]+2

address of a[2][2][1][0] is 65490, given by a[2][2][1] , 65490 given by a[2][2]+1


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

Related questions

0 votes
1 answer
0 votes
1 answer
asked by baden Sr Member (2.4k points) 6 11 17 | 642 views
0 votes
1 answer
asked by rock Expert (15k points) 15 23 31 | 54 views
0 votes
1 answer
0 votes
1 answer
asked by smith Geek (15.3k points) 17 43 67 | 32 views
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true


C Books Guide and List
C++ Books Guide and List
Best Java Books

3.8k questions

4k answers


10.7k users

3,754 questions
4,046 answers
10,709 users