Array Addition using 2d array in C || Add Two Matrices Using Multi-dimensional Arrays in C

Array Addition using 2d array in C

#include<stdio.h>
void main()
{
    int i,j;
    int a[3][4],b[3][4],c[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");
    }

    for(i=0;i<3;i++){
        for(j=0;j<4;j++){
            printf("b[%d][%d]",i,j);
            scanf("%d",&b[i][j]);
        }

    }
    for(i=0;i<3;i++){
        for(j=0;j<4;j++){
            printf("%d ",b[i][j]);
        }
        printf("\n");

    }
     printf("\n");
     printf("sum of two array is :\n");

for(i=0;i<3;i++){
    for(j=0;j<4;j++){
        c[i][j]=a[i][j]+b[i][j];
    }
}
for(i=0;i<3;i++){
    for(j=0;j<4;j++){
        printf("%d ",c[i][j]);
    }
    printf("\n");
}
}

Output:

Binary Search in C++|| Binary search algorithm 

3 thoughts on “Array Addition using 2d array in C || Add Two Matrices Using Multi-dimensional Arrays in C”

Leave a Comment