Praveen | Typing Speed Test is a very useful Software available for free Download.

C Programs to Subtract Matrix

      Subtract of two matrix are given by the user, And also given range of the matrix by the user. It is a simple method of the subtract of two matrix.


C programming code

#include<stdio.h>
#include<conio.h>


void main()
{
   int a[3][3], b[3][3], d[3][3], i, j, n;
   clrscr();
   printf("\n Enter the number of same rows and columns of matrix ");
   scanf("%d",&n);
   printf("\n Enter the elements of first matrix\n");
   for ( i = 0 ; i < n ; i++ )
      for ( j = 0 ; j < n ; j++ )
         scanf("%d",&a[i][j]);

   printf("\n Enter the elements of second matrix\n");
   for ( i = 0 ; i < n ; i++ )
     for ( j = 0 ; j < n ; j++ )
           scanf("%d",&b[i][j]);

   for ( i = 0 ; i < n ; i++ )
      for ( j = 0 ; j < n ; j++ )
         d[i][j] = a[i][j] - b[i][j];

   printf("\n difference of entered matrices:-\n");

   for ( i = 0 ; i < n ; i++ )
   {
      for ( j = 0 ; j < n ; j++ )
         printf("%d\t",d[i][j]);
      printf("\n");
   }
   getch();
   }


Output:-