Two Dimensional Array
Two dimensional array can be defined array of arrays. Two dimensional array are organized which can be represented as the collection of columns and rows. 2D array are created to implement a relational database like data structure. 2-D array are provides ease of holding the bulk of data at once.
Declaration of two dimensional array
To declare the 2D array is given below
data_type array_name[rows][columns]; int twodimen[2][3];
here, 2 is the number of rows and 3 is the number of columns.
Let’s see the example of 2D array in C language
#include<stdio.h> int main(){ int i=0,j=0; int arr[4][3]={{1,2,3},{2,3,4},{3,4,5},{4,5,6}}; for(i=0;i<4;i++){ for(j=0;j<3;j++){ printf("arr[%d] [%d] = %d \n",i,j,arr[i][j]); } } return 0; }
Output
arr[0][0] = 1 arr[0][1] = 2 arr[0][2] = 3 arr[1][0] = 2 arr[1][1] = 3 arr[1][2] = 4 arr[2][0] = 3 arr[2][1] = 4 arr[2][2] = 5 arr[3][0] = 4 arr[3][1] = 5 arr[3][2] = 6
Submit your review | |
The Technical Funda
Average rating: 0 reviews