Two Dimensional Array
It is a collection of data elements of same data type arranged in rows
and columns (that is, in two dimensions).
Declaration of Two-Dimensional Array
Type arrayName[numberOfRows][numberOfColumn];
For example,
int Sales[3][5];
Referring to Array Elements
To access the elements of a two-dimensional array, we need a pair of indices: one for
the row position and one for the column position. The format is as simple as:
name[rowIndex][columnIndex]
Examples:
cout<<A[1][2]; //print an array element
A[1][2]=13; // assign value to an array element
cin>>A[1][2]; //input element
Using Loop to input an Two-Dimensional Array from user
int mat[3][5], row, col ;
for (row = 0; row < 3; row++)
for (col = 0; col < 5; col++)
cin >> mat[row][col];