It is necessary to mention both dimensions of 2D arrays except when it is in function's parameter or if an initializer is present then first dimension can be omitted.
When used as a parameter in a function, for example,
int 2D_arr[m][n]
converted to
int (*2D_arr)[n]
Therefore, first dimension can be omitted. But, second dimension must be there to tell the compiler that the pointer 2D_arr
is a pointer to an array of n
ints.
In second case, when initializer is present
int A[][2][2]={{{1,2},{3,4}},{{4,5},{5,6}}};
the compiler uses the length of the initializer to calculate the first dimension only. The rest of the dimension must be explicitly specified at the time of declaration.