I've known that this is true:
x[4] == 4[x]
What is the equivalent for multi-dimensional arrays? Is the following true?
x[4][3] == 3[x[4]] == 3[4[x]]
Examples: Two dimensional array: int two_d[10][20]; Three dimensional array: int three_d[10][20][30]; Size of Multidimensional Arrays: The total number of elements that can be stored in a multidimensional array can be calculated by multiplying the size of all the dimensions.
A multi-dimensional array is an array with more than one level or dimension. For example, a 2D array, or two-dimensional array, is an array of arrays, meaning it is a matrix of rows and columns (think of a table). A 3D array adds another dimension, turning it into an array of arrays of arrays.
In C programming, you can create an array of arrays. These arrays are known as multidimensional arrays. For example, float x[3][4];
x[y]
is defined as *(x + (y))
x[y][z]
would become *(*(x + (y)) + z)
x[y[z]]
would become *(x + (*(y + (z))))
x[4][3]
would become *(*(x + (4)) + 3)
would become
*(*(x + 4) + 3)
3[x[4]]
would become *(3 + (*(x + (4))))
would become *(*(x + 4) + 3)
3[4[x]]
would become *(3 + (*(4 + (x))))
would become *(*(x + 4) + 3)
Which means they are all equivalent.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With