C programming , Let A and B be the two matrix. The size of matrix A is m and size of matrix B. Then, find subtraction of C, is a A and B is defined as C(ij) = A(ij) - B(ij).
#include<stdio.h>
int main(){
int a[50][50], b[50][50], c[50][50],i,j,m;
printf("enter size of matrix");
scanf("%d",&m);
printf("enter first matrix");
for(i=0;i<m;i++){
for(j=0;j<m;j++){
scanf("%d",&a[i][j]);
}
}
printf("enter second matrix");
for(i=0;i<m;i++){
for(j=0;j<m;j++){
scanf("%d",&b[i][j]);
}
}
printf("Subtraction of theese matrix is ");
for(i=0;i<m;i++){
for(j=0;j<m;j++){
c[i][j]=a[i][j]-b[i][j];
}
}
for(i=0;i<m;i++){
printf("\n");
for(j=0;j<m;j++){
printf("%d\t",c[i][j]);
}
}
return 0;
}
Comments
Leave a comment