How to subtract two matrice in c program

      No Comments on How to subtract two matrice in c program

Subtraction of two matrice

#include<stdio.h>
#include<conio.h>
void main()
{
 int a[3][3],b[3][3],c[3][3],i,j;
 clrscr();
 printf("Enter First Matrice row wise:-\n");

 for(i=0;i<3;i++)
  {
   for(j=0;j<3;j++)
    {
     scanf("%d",&a[i][j]);
    }
  }

  printf("Enter Second Matrice row wise:-\n");

 for(i=0;i<3;i++)
  {
   for(j=0;j<3;j++)
    {
     scanf("%d",&b[i][j]);
    }
  }



 for(i=0;i<3;i++)
  {
   for(j=0;j<3;j++)
    {
     c[i][j]=a[i][j]-b[i][j];
    }
  }

  printf("Subtraction of Matrice is:-\n");
  for(i=0;i<3;i++)
  {
   for(j=0;j<3;j++)
    {
     printf("%d    ",c[i][j]);

    }
    printf("\n");
  }
 getch();
}

OUTPUT:-

Subtraction of two matrice

Leave a Reply

Your email address will not be published. Required fields are marked *