Multi Dimensional array in C
In C programming, we can have arrays of any dimension. But we rarely use higher dimension arrays. At most, we can use an array of 3 dimensions called 3D arrays. In C 3D array can be declared as follows:
datatype arrayName[dim1Size][dim2Size][dim3Size];
To declare 3D array of integers with dimension: 2X3X4
int threeDArray[2][3][4];
Initialization of 3D arrays
int threeDArray[2][3][4] = {
{
{1, 2, 3, 4}, // First block
{5, 6, 7, 8}, // Second block
{9, 10, 11, 12} // Third block
},
{
{13, 14, 15, 16}, // Fourth block
{17, 18, 19, 20}, // Fifth block
{21, 22, 23, 24} // Sixth block
}
};