Initializing 2D Array : Two dimensional Array in C Programming
Initializing Array
Method 1 : Initializing all Elements
int a[3][2] = {
{ 1 , 4 },
{ 5 , 2 },
{ 6 , 5 }
};- Declared array is of size 3 X 2 .
- Declared array contain total 6 elements.
Row 1 : { 1 , 4 },
Row 2 : { 5 , 2 },
Row 3 : { 6 , 5 }- Each Row is initialized Independently .
- Here -
a[0][0] = 1 a[0][1] = 4
Method 2 :
- Initialize all Array elements but this initialization is much straight forward .
- All values are assigned sequentially and row-wise
int a[3][2] = {1 , 4 , 5 , 2 , 6 , 5 };Method 3 : Only Some Elements could be initialized
int a[3][2] = {
{ 1 },
{ 5 , 2 },
{ 6 }
};Multidimensional Array : Refer this Link




