// A C Program of Sum of Two Matrix
#include<stdio.h>#include<conio.h>
void main()
{
int a[2][2],b[2][2],c[2][2],i,j;
clrscr();
printf("Enter the value of First 2 x 2 Matrix :a ");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("Enter the element of [%d][%d]",i,j);
scanf("%d",&a[i][j]);
}
}
printf("Enter the value of Second 2 x 2 Matrix :b ");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("Enter the element of [%d][%d]",i,j);
scanf("%d",&b[i][j]);
}
}
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
c[i][j]=a[i][j]+b[i][j];
}
}
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf(" %d\t",c[i][j]);
}
printf("\n");
}
getch();
}
Output:
0 Comments