Aim:-
Write a program to add two matrices. (Using 2-D arrays)
Source Code:-
#include<Stdio.h>
int main()
{
int
a[10][10],b[10][10],c[10][10],m,n,i,j;
printf("Enter
the order the matrix=");
scanf("%d%d",&m,&n);
printf("Enter
the element of first matrix=\n");
for(i=0;i<m;i++)
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);
printf("Enter
the 2nd matrix=\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];
printf("Resultant
matrix is=\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
printf("%d",c[i][j]);
}
printf("\n");
return 0;
}
Output
0 Comments
How did you like it, please comment by posting my post