/* WAP to find sum of matrix */
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,col,row;
int matA[10][10],matB[10][10],matsum[10][10];
clrscr();
printf("Enter the order:");
scanf("%d %d",&row,&col);
printf("Enter the elements of Matrix A:\n");
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
scanf("%d",&matA[i][j]);
}
}
printf("Enter the elements of Matrix B:\n");
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
scanf("%d",&matB[i][j]);
}
}
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
matsum[i][j]=matA[i][j]+matB[i][j];
}
}
printf("The sum of Matrix is:");
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
printf("%d",matsum[i][j]);
}
}
getch();
}
No comments:
Post a Comment