#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][3],b[3][3],c[3][3],i,j,k,sum=0;
clrscr();
printf("Enter the element of 1st 3*3 matrix:");
for(i=0;i<3;i++)
for(j=0;j<3;j++)
scanf("%d",&a[i][j]);
printf("Enter the element of 2nd 3*3 matrix:");
for(i=0;i<3;i++)
for(j=0;j<3;j++)
scanf("%d",&b[i][j]);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
c[i][j]=a[i][j]+b[i][j];
}
}
printf("\n1st Matrix is :\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("\t%d",a[i][j]);
}
printf("\n");
}
printf("\n2nd Matrix is :\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("\t%d",b[i][j]);
}
printf("\n");
}
printf("\nOutput Matrix is :\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("\t%d",c[i][j]);
}
printf("\n");
}
getch();
}
#include<conio.h>
void main()
{
int a[3][3],b[3][3],c[3][3],i,j,k,sum=0;
clrscr();
printf("Enter the element of 1st 3*3 matrix:");
for(i=0;i<3;i++)
for(j=0;j<3;j++)
scanf("%d",&a[i][j]);
printf("Enter the element of 2nd 3*3 matrix:");
for(i=0;i<3;i++)
for(j=0;j<3;j++)
scanf("%d",&b[i][j]);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
c[i][j]=a[i][j]+b[i][j];
}
}
printf("\n1st Matrix is :\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("\t%d",a[i][j]);
}
printf("\n");
}
printf("\n2nd Matrix is :\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("\t%d",b[i][j]);
}
printf("\n");
}
printf("\nOutput Matrix is :\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("\t%d",c[i][j]);
}
printf("\n");
}
getch();
}
No comments:
Post a Comment