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 

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

  1. Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?

    Reply

Leave a Comment