Monday, 12 June 2017 02:28

## Two Dimensional Array in C

Written by
Rate this item

The two dimensional array in C language is represented in the form of rows and columns, also known as matrix. It is also known as array of arrays or list of arrays.

The two dimensional, three dimensional or other dimensional arrays are also known as multidimensional arrays.

## Declaration of two dimensional Array in C

We can declare an array in the c language in the following way.

1. data_type array_name[size1][size2];

A simple example to declare two dimensional array is given below.

1. int twodimen;

Here, 4 is the row number and 3 is the column number.

## Initialization of 2D Array in C

A way to initialize the two dimensional array at the time of declaration is given below.

1. int arr={{1,2,3},{2,3,4},{3,4,5},{4,5,6}};

## Two dimensional array example in C

1. #include <stdio.h>
2. #include <conio.h>
3. void main(){
4. int i=0,j=0;
5. int arr={{1,2,3},{2,3,4},{3,4,5},{4,5,6}};
6. clrscr();
7.
8. //traversing 2D array
9. for(i=0;i<4;i++){
10.  for(j=0;j<3;j++){
11.    printf("arr[%d] [%d] = %d \n",i,j,arr[i][j]);
12.  }//end of j
13. }//end of i
14.
15. getch();
16. }

#### Output

```arr = 1
arr = 2
arr = 3
arr = 2
arr = 3
arr = 4
arr = 3
arr = 4
arr = 5
arr = 4
arr = 5
arr = 6``` ### Anish Sir

"I am delighted once again to pen the welcome note to the Tosh!Yas Technologies ."

Call +91 74 88 34 7779  | Email : anishsingh@live.com

### Latest from Anish Sir

More in this category: « C Array C Functions »