Two Dimensional Array in C
What is Two Dimensional Array in C ?
An array of two dimension having rows and columns like of matrix is known as two dimensional array or 2-D array.
Two dimensional array can be of int,char,float etc.. type.
Syntax to declare Two Dimansional Array
data_type arrayName[rowsize][colsize];
This is called a two-dimensional array. The arraySize must be an integer constant greater than zero and type can be any valid C data type. For example, to declare an array with size 2 rows and 3 columns array called num of type int, use this statement:
int num[2][3];
Now num is available array which can hold values with 2 rows and 3 columns.
Example 1
Output
10 20
30 40
30 40
Example 2
Output
Enter array elements
10
20
30
40
Array elements are :
10 20
30 40
Example 3
Output
Array elements are:
10 20
30 40
10 20
30 40