Subtraction of two matrix :
Code:
#include<stdio.h>
void main()
{
int n;
printf("Enter the size of the matrix:\n");
scanf("%d",&n);
int a[n][n],b[n][n],c[n][n],i,j;
printf("Enter elements of 1st matrix:\n");
for(i=0;i<=n-1;i++)
{
for(j=0;j<=n-1;j++)
scanf("%d",&a[i][j]);
}
printf("Enter the elements of 2nd matrix:\n");
for(i=0;i<=n-1;i++)
{
for(j=0;j<=n-1;j++)
scanf("%d",&b[i][j]);
}
printf("The subtraction is:\n");
for(i=0;i<=n-1;i++)
{
for(j=0;j<=n-1;j++)
printf("%d\t",c[i][j]=a[i][j]-b[i][j]);
printf("\n");
}
getch();
}
Output:
Give your feedback comment below!
Comments
Post a Comment
Give your feedback!
DO NOT SPAM !!
NO THIRD PARTY PROMOTIONAL LINK !!!! (else comment will be deleted.)