Three-Dimensional Array

Three-Dimensional Array

A three-dimensional array can be thought of as an array of arrays of arrays. The outer array has three elements, each of which is a two-dimensional array of four one-dimensional arrays, each of which contains two integers.

The general form of a multidimensional array declaration is:
Variable type       Array name[Size1][Size2][Size3] . . .[SizeN];
Eg- int m;

Arrays of more than three dimensions are not often used because of the amount of memory they require.

A one-dimensional array of two elements is constructed first. Then four such one dimensional arrays are placed one below the other to give a two dimensional array containing four rows. Then, three such two dimensional arrays are placed one behind the other to yield a three dimensional array containing three 2-dimensional arrays.

we initialize a three-dimensional array as :
int arr =
{
{ 2, 4 }, { 7, 8 }, { 10, 8 }, { 3, 14 },
{ 3, 5 }, { 14, 3 }, { 51, 10 }, { 8, 3 },
{ 5, 6 }, { 8, 10 }, { 3, 5 }, { 45, 32 }
} ;

The following figure is visualizing the situation of 3-D array : Again remember that the arrangement shown above is only conceptually true. In memory the same array elements are stored linearly as shown in Figure. 