write two matrix in c addition
///program----///
// write two matrix addition [2*2]//
#include<stdio.h>
#include<conio.h>
int main()
{
int A[2][2],B[2][2],C[2][2],i,j;
for( i=0; i<2; i=i+1)
{
for(j=0; j<2; j=j+1)
{
scanf("%d",&A[i][j]);
}
}
for(i=0; i<2; i=i+1)
{
for(j=0; j<2; j=j+1)
{
scanf("%d",&B[i][j]);
}
}
for(i=0; i<2; i=i+1)
{
for(j=0; j<2; j=j+1)
{
C[i][j]=A[i][j]+B[i][j];
printf("%d\t",C[i][j]);
}
printf("\n");
}
getch();
return 0;
}
Output ---
3 4
2 5
3 6
7 8
6 10
9 13
Comments
Post a Comment