c program to subtract two 3*3 matrices


/*c program to subtract two 3*3 matrices*/
#include<stdio.h>
#include<conio.h>
void main()
  {
    int m1[3][3],m2[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 subtraction proceeds as follows...*/
   for(i=0;i<3;++i)
   for(j=0;j<3;++j)
       msub[i][j]=m1[i][j]-m2[i][j];
/*subtraction matrix as follows...*/
   for(i=0;i<3;++i)
   {
   for(j=0;j<3;++j)
   printf("%3d",msub[i][j]);
   printf("\n");
   }
getch();
}



type in 9 integer number first matrix:
1 2 3
3 2 1
4 5 6

type in 9 integer number of second matrix
6 5 4
3 2 1
2 3 1


Subscription of matrix
-5 -3 -1
 0  0  0
 2  2  5


Related Posts Plugin for WordPress, Blogger...