//Program to add two matrices
#include<stdio.h>
#include<conio.h>
void
main()
{
int
i,j,a[3][3],b[3][3];
clrscr();
//Entry of elements of first matrix
printf("Enter
the elements of first matrix\n");
for(i=1;i<=3;i++)
{
for(j=1;j<=3;j++)
{
scanf("%d",&a[i][j]);
}
}
//First Matrix
printf("First
Matrix is\n");
for(i=1;i<=3;i++)
{
for(j=1;j<=3;j++)
{
printf("\t%d",a[i][j]);
}
printf("\n\n");
}
//Entry of elements of second matrix
printf("Enter
the elements of second matrix\n");
for(i=1;i<=3;i++)
{
for(j=1;j<=3;j++)
{
scanf("%d",&b[i][j]);
}
}
//Second Matrix
printf("Second
Matrix is\n");
for(i=1;i<=3;i++)
{
for(j=1;j<=3;j++)
{
printf("\t%d",b[i][j]);
}
printf("\n\n");
}
//Addition of Matrices
printf("After
Addition the matrix is\n");
for(i=1;i<=3;i++)
{
for(j=1;j<=3;j++)
{
printf("\t%d",a[i][j]+b[i][j]);
}
printf("\n\n");
}
getch();
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.