Write C program to subtract two matrices.
#include<stdio.h>
#include<math.h>
int
a[10][10],b[10][10],sub[10][10];
int row,col,i,j;
main()
{
int i,j;
printf("\n\t\t MATRIX
SUBTRACTION\n");
printf("\n\t\t**************\n");
printf("\n INPUT:");
printf("\n*********\n");
printf("\n Enter the row
:");
scanf("%d",&row);
printf("\n Enter the column
:");
scanf("%d",&col);
printf("\n Enter the
value:\n");
for(i=0;i<row;i++)
for(j=0;j<col;j++)
{
scanf("%d",&a[i][j]);
}
for(i=0;i<col;i++)
for(j=0;j<row;j++)
{
scanf("%d",&b[i][j]);
}
for(i=0;i<row;i++)
for(j=0;j<col;j++)
sub[i][j]=a[i][j]-b[i][j];
printf("\n");
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
printf("%d\t",sub[i][j]);
printf("\n");
}
getch();
}
0 comments:
Feel free to contact the admin for any suggestions and help.