Friday, 24 May 2013

Addition of two Matrices


#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,a[3][3],b[3][3],sum[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\nSum of two matrices is\n");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
sum[i][j]=a[i][j]+b[i][j];
printf("\na[%d][%d] = %d ",i,j,sum[i][j]);

}
printf("\n");
}

getch();
}
                               

No comments:

Post a Comment

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