/* Program to find
the sum of two matrixes */
#include<stdio.h>
#include<conio.h>
void
main()
{
int
a[100][100],b[100][100],c[100][100],n,m,i,j;
clrscr();
printf("Enter the number of rows and
columns:\n");
scanf("%d%d",&n,&m);
printf("\nEnter the elements of
Matrix:A-->\n");
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("\nEnter the elements of
Matrix:B-->\n");
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
scanf("%d",&b[i][j]);
}
}
printf("\n\nSum of two matrix:\n");
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
c[i][j]=a[i][j]+b[i][j];
printf("\t%d",c[i][j]);
}
printf("\n");
}
getch();
}
OUTPUT
Enter
the number of rows and columns:
3
2
Enter
the elements of Matrix:A-->
3
4
5
6
1
2
Enter
the elements of Matrix:B-->
4
5
3
2
5
1
Sum
of two matrix:
7
9
8
8
6
3
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.