C++: Multidimensional Arrays
Multidimensional arrays in C++ are a lot like normal arrays.
You create a multidimensional array like so:
int ArrayOne[][5]={{3, 24, 55, 72, 12}, {18, 88, 7, 66, 34}};
You use two square brackets as the first is for the number of rows, and the second is for the number of columns in each row.
Unfortunately in C++ each row must have the same number of columns.
Next to call the array we simply use the row and column of the element we want to call:
cout << ArrayOne[0][3] << endl;
In the above example 72 would be displayed.
And in this example 18 would be displayed:
cout << ArrayOne[1][0] << endl;
Back to C++

