Using multi-dimensional arrays in functions
Now that we can declare, initialize, and access arrays of many dimensions, we are ready to create functions to manipulate them. We'll proceed as follows:
- First, let's create a function to initialize a 2D array and a function to initialize a 3D array, as follows:
void initialize2DArray( int col, int row, int array[row][col] ){ Â Â for( int j = 0 ; j < row ; j++ )Â Â {// j : 0..(row-1) Â Â Â Â for( int i = 0 ; i < col ; i++ )Â Â {// i : 0.. Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // (col-1) Â Â Â Â Â Â array[j][i] = (10*(j+1)) + (i+1); Â Â Â Â } Â Â } } void intialize3DArray( int x, int y, int z, int array[z][y][x] ){ Â Â for( int k...