C Program to Add two Matrix

 

#include<stdio.h>

#include<stdlib.h>

int main(){

int m,n;

system("clear");

printf("Enter the number of Rows : ");

scanf("%d",&m);

printf("Enter the Number of Columns :");

scanf("%d",&n);

int arr_1[m][n],arr_2[m][n];

printf("\nFirst Matrix: \n");

// Taking input of First Matrix . . .

for(int i=0;i<m;i++){

for(int j=0;j<n;j++){

printf("a[%d][%d]",i+1,j+1);

scanf("%d",&arr_1[i][j]);

}

}

printf("\n Second Matrix: \n");


// Taking input of Third Matrix . . .

for(int i=0;i<m;i++){

for(int j=0;j<n;j++){

printf("b[%d][%d]",i+1,j+1);

scanf("%d",&arr_2[i][j]);

}

}

printf("Two Matrices Are : \n\n");

// Printing the First Matrix - - - -

for(int i=0;i<m;i++){

printf("|");

for(int j=0;j<n;j++){

printf(" %d ",arr_1[i][j]);

}

printf("|\n");

}

printf("\n");


// Printing the Second Matrix - - - -

for(int i=0;i<m;i++){

printf("|");

for(int j=0;j<n;j++){

printf(" %d ",arr_2[i][j]);

}

printf("|\n");

}

printf("\n");

printf("Evaluating the Sum :\n");

for(int i=0;i<m;i++){

printf("|");

for(int j=0;j<n;j++){

printf(" %d ",arr_1[i][j]+arr_2[i][j]);

}

printf("|\n");

}


}

Popular posts from this blog

C program to convert decimal to Binary

C program to Convert Decimal to Hexadecimal