logo
Multi - Dimensional Arrays
A list of items can be given one variable name using more than two subscripts and such a variable is called Multi-dimensional array. 
Three Dimensional Arrays :

The Three dimensional array can be declared as

  Syntax :
<datatype> <array_name>[sizeofno.oftwoDimArray] [sizeofrow] [sizeofcolumn];
Initializing Three- Dimensional Arrays :

Like the one-dimensional arrays, three-dimensional arrays may be initialized by following their declaration with a list of initial values enclosed in braces.

int table[2][2][3] = {0,0,0,1,1,1,6,6,6,7,7,7};

This initializes the elements of first two dimensional(matrix) first row to zero’s and the second row to one’s and second matrix elements are first row to six’s and the second row to seven’s.

This initialization is done row by row.

The above statement can be equivalently written as

int table[2][3] = {{{0,0,0},{1,1,1}},{{0,0,0},{1,1,1}}}

We can also initialize a two – dimensional array in the form of a matrix as shown.

int table[2][3] = { 
     {
        {0,0,0}, 
      	{1,1,1}
      },
       {
        {6,6,6}, 
      	{7,7,7}
        } 

    } ;