Two Dimensional Arrays
A list of things is often given one variable name using two subscripts and such a variable is named a two – subscripted variable or a two – dimensional array. 2D arrays are generally known as matrices.
- There might be situations where a table of values will need to be Consider a table of students with notes in three contents.

The above table contains a complete of 15 values.
- We can think of this table as a matrix consisting of 5 rows & 3
- Each row represents marks of student # 1 in all (different)
- Each column represents the subject-wise marks of all
In mathematics, we represent a specific value during a matrix by using two subscripts like Vij. Here V denotes the entire matrix Vij refers to the value in the “ i ”th row and “ j ”th column.
For example, within the above table, V23 refers to the worth “80”. C allows us to define such tables of things by using two-dimensional arrays.
They can be declared as:

The above table are often defined in C as
int V[5][3];
Initialization of 2D Array
There are some ways to initialize two Dimensional arrays.
int disp[2][4] = { {10, 20, 12, 43}, {14, 25, 16, 67}};
or
int disp[2][4] = { 10, 20, 12, 43, 14, 25, 16, 67};
Things to keep in mind when initializing the 2D table –
When we give values during one-dimensional array declaration, we don’t need to mention dimension. But that’s not the case with a 2D array; you must specify the second dimension even if you are giving values during the declaration. Let’s understand this with the assistance of few examples .
- int abc[2][2] = {1, 2, 3 ,4 } // Valid declaration
- int abc[][2] = {1, 2, 3 ,4 } // Valid declaration
- int abc[][] = {1, 2, 3 ,4 } // Invalid declaration – you must specify second dimension
- int abc[2][] = {1, 2, 3 ,4 } //Invalid because of the same reason mentioned above
Storing Data into 2D array
.....
int abc[5][4];
.....
for(i=0; i<=4; i++) //loop for first dimension which is 5 here
for(j=0;j<=3;j++) //loop for 2D of array which is 4 in this example
{
printf("Enter value for abc[%d][%d]:", i, j);
scanf(“%d”, &abc[i][j]);
}