Yes, Savage, you are right.
In the above example, there are 2 2D arrays.
You can also have arrays with 4 or more dimensions. But you better not use them, because it's hard to visualise how they work.
In most cases a 3D array is hard, so you better stick with 1D or 2D arrays.
You can see an array as a list of elements. If you just have 1 element (for example an integer), you can create it as follow:
- int a = 5;
-
int b = 6;
-
int c = 12045;
In some cases you don't want a new variable for each element (number), so you create an array of integers. This is just a list of integers:
- int d[3] = {5, 6, 12045};
In this example, you create a 1D array (because you specify just one size of the array) which contains 3 elements.
To create a 2D or more dimensional array, you have to specify more sizes of the array. A 2D array can best be visualized as a table, with rows and columns:
You can look at this array as it's a table with 4 rows and 3 columns.
3D arrays are like cubes, and need 3 sizes:
When you want to create a more dimensional array, you need to specify more size. But it's hard to visualize such a array.