We can initializearray3Dat the declaration stage in several ways, as follows:
int array3D[3][4][5] = {0};
array3D is initialized with all of its elements set to 0. Note that we cannot use our constant sizes to initialize the array at declaration. Try it and see what error message you get.
To give each element a different value at the declaration stage, we would initialize it as follows:
int array3D[size3D][size2D][size1D] =
{ { {111 , 112 , 113 , 114 , 115 },
{121 , 122 , 123 , 124 , 125 } },
{ {211 , 212 , 213 , 214 , 215 },
{221 , 222 , 223 , 224 , 225 } },
{ {311 , 312 , 313 , 314 , 315 },
{321 , 322 , 323 , 324 , 325 } } };
In this declaration, the first Z layer of elements is given the values111..115and121..125. The second...