Search This Blog

C program for calculating difference of two matrices

//coded by Z
#include<stdio.h>
void main()
{
int a[2][2],b[2][2],d[2][2],i,j;
clrscr();
printf("\nEnter first matrix\t\n");
for(i=0;i<2;i++)
for(j=0;j<2;j++){
scanf("%d",&a[i][j]);}
printf("\nEnter second matrix\t\n");
for(i=0;i<2;i++)
for(j=0;j<2;j++){
scanf("%d",&b[i][j]);}
for(i=0;i<2;i++)
for(j=0;j<2;j++)
d[i][j]=a[i][j]-b[i][j];
printf("\nDifference of two matrices\n");
for(i=0;i<2;i++)
{      printf("\n\n  ");
for(j=0;j<2;j++){
printf("%d\t",d[i][j]);}

}
getch();
}


No comments:

Post a Comment