
524 Arrays
12.11 THREE- OR MULTI-DIMENSIONAL ARRAYS
The ‘C++’ program helps in creating an array of multi dimensions. The compiler determines the
restrictions on it. The syntax of the declaration of multi-dimensional arrays is as follows:
Data Type_Arrayname [S1][S2][S3]...[Si];
where Si is the size of the i
th
dimensions.
Three-dimensional arrays can be initialized as follows.
int mat[3][3][3] = { 1,2,3, 4,5,6, 7,8,9, 1,4,7, 2,5,8,
3,6,9, 1,4,4, 2,4,7, 8,8,5};
A three-dimensional array can be considered an array of arrays of arrays. The outer array contains
three elements. The inner array is two dimensional with regard to size [3][3].
12.14 Write a ...