Write a C program to find sum of two matrices
#include<stdio.h>
void main()
{
int m, n, i, j, a[10][10], b[10][10], c[10][10];
printf("Enter the order of matrices\n");
scanf("%d%d",&m, &n);
printf("Enter elements of matrix A\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("Enter elements of matrix B\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&b[i][j]);
}
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
c[i][j]=a[i][j]+b[i][j];
}
Write a C program to find sum of two matrices
}
printf("Sum of two matrices \n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("%d\t",c[i][j]);
}
printf("\n");
}
}
Comments
Post a Comment