c program to add two 3*3 matrices
/*c program to add two 3*3 matrices*/
#include<stdio.h>
#include<conio.h>
void main()
{
int m1[3][3],m2[3][3],madd[3][3],msub[3][3];
int i,j;
clrscr();
printf("type in 9 integer number of first matrix:\n");
for(i=0;i<3;++i)
for(j=0;j<3;++j)
scanf("%d",&m1[i][j]);
printf("\n type in 9 integer number of first matrix:\n");
for(i=0;i<3;++i)
for(j=0;j<3;++j)
scanf("%d",&m2[i][j]);
/*matrix addition proceeds as follows...*/
for(i=0;i<3;++i)
for(j=0;j<3;++j)
madd[i][j]=m1[i][j]+m2[i][j];
/*added matrix as follows...*/
for(i=0;i<3;++i)
{
for(j=0;j<3;++j)
printf("%3d",madd[i][j]);
printf("\n");
}
getch();
}
type in 9 number of first matrix:
1 2 3
1 2 4
2 1 3
type in 9 integer number of first matrix:
8 6 5
7 8 9
4 5 6
9 8 8
8 10 13
6 6 9
Comments