// Program by Akash Tripathi (@proakash256)
#include <stdio.h>
int main()
{
int r;
printf("Enter the number of Rows and Columns: ");
scanf("%d" , &r);
int ar1[r][r];
int ar2[r][r];
printf("\nEnter the elements (row wise) of the First Matrix:\n");
for(int i = 0; i < r; i = i + 1)
for(int j = 0; j < r; j = j + 1)
scanf("%d" , &ar1[i][j]);
printf("\nEnter the elements (row wise) of the Second Matrix:\n");
for(int i = 0; i < r; i = i + 1)
for(int j = 0; j < r; j = j + 1)
scanf("%d" , &ar2[i][j]);
printf("\nThe First Matrix is :\n\n");
for(int i = 0; i < r; i = i + 1)
{
for(int j = 0; j < r; j = j + 1)
printf("%d\t" , ar1[i][j]);
printf("\n");
}
printf("\nThe Second Matrix is :\n\n");
for(int i = 0; i < r; i = i + 1)
{
for(int j = 0; j < r; j = j + 1)
printf("%d\t" , ar2[i][j]);
printf("\n");
}
printf("\nThe Sum of both the matrices is :\n\n");
for(int i = 0; i < r; i = i + 1)
{
for(int j = 0; j < r; j = j + 1)
printf("%d\t" , (ar1[i][j] + ar2[i][j]));
printf("\n");
}
printf("\n");
return 0;
}
Comments
Post a Comment