/* Program to add two matrices */
#include <stdio.h>
#include <conio.h>
int main()
{
int a[10][10], b[10][10],c[10][10],i,j;
printf("Enter a");
for(i=0;i<2;i++) //get the matrix A
for(j=0;j<2;j++)
scanf("%d",&a[i][j]);
printf("Enter b");
for(i=0;i<2;i++) //get the matrix B
for(j=0;j<2;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]; //adding two matrices
}
}
printf("Added Matrix is \n");
for(i=0;i<2;i++)
for(j=0;j<2;j++)
printf("%d ",c[i][j]);
getch();
return 0;
}
Comments
Post a Comment