SUM OF TWO GIVEN MATRICES - C-Tutorial

Latest

Monday, 26 September 2016

SUM OF TWO GIVEN MATRICES

/* SUM OF TWO GIVEN MATRICES */


#include<stdio.h>
#include<conio.h>
main()
{
int m,n,i,j,a[5][5],b[5][5],c[5][5];
clrscr();
printf("\n Enter the row and column size:");
scanf("%d%d",&m,&n);
printf("\n Enter the 'A' Matrix elements ");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&a[i][j]);
}
}

printf("\n Enter the 'B' Matrix elements ");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&b[i][j]);
}
}

printf("\n The sum of two matrices is ");
for(i=0;i<m;i++)
{
printf("\n");
for(j=0;j<n;j++)
{
c[i][j]=a[i][j]+b[i][j];
printf("%3d",c[i][j]);
}
}
getch();
}

No comments:

Post a Comment