TASK-
Write a C program to Subtract Two Matrix.
STEPS TO BE TAKEN:
1) Matrix is a type of array.
2) Array can have multiple dimension for example 1D,2D.
3) For getting inputs and giving outputs in 1D we use one loop, Same for when we have 2D we use 2 loops.
4) We will add two matrices using two loops.
CODE:
#include<stdio.h>
int main(){
int matA[3][3],matB[3][3],MatC[3][3];
int i,j;
for (i=0;i<3;i++)
{
for (j=0;j<3;j++)
{
printf("\nEnter [%d %d] Entry of MatA: ",i+1,j+1);
scanf("%d",&matA[i][j]);
}
}
printf("\n\n");
for (i=0;i<3;i++)
{
for (j=0;j<3;j++)
{
printf("\nEnter [%d %d] Entry of MatB: ",i+1,j+1);
scanf("%d",&matB[i][j]);
}
}
printf("\n\nHere is the Sum\n\n");
for (i=0;i<3;i++)
{
for (j=0;j<3;j++)
{
MatC[i][j]=matA[i][j]-matB[i][j];
printf("%d\t",MatC[i][j]);
}
printf("\n");
}
getchar();
return 0;
}
EXPECTED OUTPUT:
Really good, Kindly post Transpose program
ReplyDeleteAlready uploaded follow the link::
Deletehttps://let-us-c-the-program.blogspot.com/2022/01/write-c-program-to-find-transpose-of.html