Friday 7 March 2014

Filled Under:

write a program to add two matrix using array??

#include<stdio.h>
#include<conio.h>
main()
{
int x[3][3],y[3][3],z[3][3],i,j,k;

printf("enter the first matrix");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
scanf("%d",&x[i][j]);
}
printf("enter the second matrix");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
scanf("%d",&y[i][j]);
}
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
z[i][j]=x[i][j]+y[i][j];
}
printf("the matrix addition is");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
printf("%d\t",z[i][j]);
printf("\n");
}
getch();
}


0 comments:

Post a Comment