Friday, 24 May 2013

Diffference of two matrices


#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,a[3][3],b[3][3],diff[3][3];
printf("Enter the elements of array A\n");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
printf("\na[%d][%d] = ",i,j);
scanf("%d",&a[i][j]);
}
printf("\n");
}

printf("\nEnter the elements of array B\n");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
printf("\na[%d][%d] = ",i,j);
scanf("%d",&b[i][j]);
}
printf("\n");
}

printf("\n\nThe elements of array A are\n");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
printf("\na[%d][%d] = %d ",i,j,a[i][j]);
}
printf("\n");
}

printf("\n\nThe elements of array B are\n");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
printf("\na[%d][%d] = %d ",i,j,b[i][j]);
}
printf("\n");
}


printf("\n\ndiffrence of two matrices is\n");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
diff[i][j]=a[i][j]-b[i][j];
printf("\na[%d][%d] = %d ",i,j,diff[i][j]);

}
printf("\n");
}

getch();
}

No comments:

Post a Comment

full details in json
Proudly Powered by Blogger.
back to top