Multi Dimensional Array

Syntax

int a[2][2][2]; // declaration 

// declaration with initialization
int a[2][2][3]={
    {
      {1,3,2},
      {2,4,0}
    },
    {
      {5,6,1},
      {7,8,4}
    }
};
    
 

Example for multi dimensional array in c

#include<stio.h>
#include<conio.h>
int main(){
    int i,j,k;
    int a[2][2][3]={
    {
      {1,3,2},
      {2,4,0}
    },
    {
      {5,6,1},
      {7,8,4}
    }
};

    for(i=0;i<2;i++){
        for(j=0;j<2;j++){
            for(k=0;k<3;k++){
                printf(" %d ",a[i][j][k]);
            }
            printf("\n");
        }

    }
return 0;    
}

Output:

1 3 2
2 4 0
5 6 1
7 8 4

Comments