# Definition of two-dimensional array in C language

2022-02-03 00:38:29

int a[2][3]={ {1},{2},{3,4}}; Why is it wrong

{1},{2},{3,4} Here you are 3 individual {}, Should be int a[3][3]
The number of rows and columns can be more than the number in initialization , But not less .
The smallest two-dimensional array in this topic is 3 That's ok 2 Column , therefore , The smallest two-dimensional array is int a[3][2], The number of rows of the array must be greater than or equal to 3, The number of columns must be greater than or equal to 2.
int a[3][2] ={ {1},{2},{3,4}};
int a[3][3] ={ {1},{2},{3,4}};
int a[4][2] ={ {1},{2},{3,4}};
int a[4][3]={ {1},{2},{3,4}};
These kinds of writing are OK .

You wrote this column backwards , Change to a[3][2] That's right ,2 and 3 Turn it upside down
Should be
int a[3][2]={ {1},{2},{3,4}};

int a[5][3]={ {80,75,92}, {61,65,71}, {59,63,70}, {85,87,90}, {76,77,85} }; Like this ,
Look at your { {1},{2},{3,4}}, Let's look at the definition of two dimensions