2D Arrays in C || C Multidimensional Arrays

Understanding 2D Arrays in C

Multidimensional arrays in C are those that have more than one dimension. They can be compared to a table with columns and rows. In C, a multidimensional array can be declared using the following syntax:

data_type array_name[row_size][column_size];

For instance, we may write the following to declare a 2D array with 3 rows and 4 columns of integers:

int arr[3][4];

Example in C

#include<stdio.h>
void main(){
int i,j;
int a[3][4];
for(i=0;i<3;i++){
    for(j=0;j<4;j++){
            printf("a[%d][%d]",i,j);
        scanf("%d",&a[i][j]);
    }

}
for(i=0;i<3;i++){
    for(j=0;j<4;j++){

        printf("%d ",a[i][j]);
    }
    printf("\n");
}}

Output:

A Comprehensive Guide on Prime Number in C

2 thoughts on “2D Arrays in C || C Multidimensional Arrays”

Leave a Comment