2D Array in C


The two-dimensional array can be defined as an array of arrays. The 2D array is organized as matrices which can be represented as the collection of rows and columns. However, 2D arrays are created to implement a relational database lookalike data structure. It provides ease of holding the bulk of data at once which can be passed to any number of functions wherever required.

Source Code

//2D Arrays
#include<stdio.h>
int main()
{
    int a[100][100],b[100][100],c[100][100];
    int i,j,n,m;
    printf("\nEnter The Rows : ");
    scanf("%d",&n);
    printf("\nEnter The Columns : ");
    scanf("%d",&m);
 
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            printf("Enter The Value of a[%d][%d] : ",i,j);
            scanf("%d",&a[i][j]);
        }
    }
 
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            printf("Enter The Value of b[%d][%d] : ",i,j);
            scanf("%d",&b[i][j]);
        }
    }
 
     for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            c[i][j]=a[i][j]+b[i][j];
            printf("\t%d",c[i][j]);
        }
        printf("\n");
    }
    return 0;
}
 
To download raw file Click Here

List of Programs


Sample Programs


Switch Case in C


Conditional Operators in C


Goto Statement in C


While Loop Example Programs


Looping Statements in C

For Loop Example Programs


Array Examples in C

One Dimensional Array


Two Dimensional Array in C


String Example Programs in C


Functions Example Programs in C


Learn All in Tamil © Designed & Developed By Tutor Joes