Subtraction of matrix (2 Dimensional)

#include<stdio.h>
void main()
{
int i,j,m1,m2,n1,n2,a[10][10],b[10][10],c[10][10];

printf("Enter the row and column  of Matrix A\n");
scanf("%d %d",&m1,&n1);
printf("Enter the row and column of Matrix B\n");
scanf("%d%d",&m2,&n2);

if(m1==m2 && n1==n2)
{
printf("Enter the Matrix A\n");
for(i=0;i<m1;i++)
{
for(j=0;j<n1;j++)
scanf("%d",&a[i][j]);
}


printf("\nEnter the Matrix B\n");
for(i=0;i<m2;i++)
{
for(j=0;j<n2;j++)
scanf("%d",&b[i][j]);
}

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

printf(" Subtraction of Matrix \n");
for(i=0;i<m1;i++)
{
for(j=0;j<n2;j++)
{
printf("%d\t",c[i][j]);
}
printf("\n");
}
}

else
{
printf("Matrix Subtraction is Impossible");
}
}

No comments:

Post a Comment

Thank you for using this blog.