Q.no program to calculate the addition of the two matrices in c-programming
In this program, we will adding two matrices in c-language of the same order 3x3. i.e the number of rows and column are same.
In this program user is asked to enter the values of the first and the last matrices of 3x3 order then the program return the output.
#include<Stdio.h>
#include<conio.h>
main()
{
int a[3][3],b[3][3],c[3][3],i,j;
printf("enter the value of the first matrices");
for(i=0;i<=2;i++)
for(j=0;j<=2;j++)
scanf("%d",&a[i][j]);
printf("enter the value of the second matrices");
for(i=0;i<=2;i++)
for(j=0;j<=2;j++)
scanf("%d",&b[i][j]);
printf("the sum of the two matrices \n");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
c[i][j]=a[i][j]+b[i][j];
printf("%d ",c[i][j]);
}
printf("\n");
}
getch();
}
output are follow:-

No comments:
Post a Comment