#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][3],b[3][3],i,j,k,res[3][3];
clrscr();
printf("\n enter 9 values of d 1st array:");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
scanf("%d",&a[i][j]);
}
}
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
printf("\t %d",a[i][j]);
}
printf("\n");
}
printf("\n enter 9 values of d 2nd array :");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
scanf("%d",&b[i][j]);
}
}
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
printf("\t %d",b[i][j]);
}
printf("\n");
}
printf("\n the product of above 2 matrices are:");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
res[i][j]=0;
for(k=0;k<=2;k++)
{
res[i][j]+=a[i][k]*b[k][j];
}
}
}
for(i=0;i<=2;i++)
{
printf("\n");
for(j=0;j<=2;j++)
{
printf("\t %d",res[i][j]);
}
}
getch();
}
#include<conio.h>
void main()
{
int a[3][3],b[3][3],i,j,k,res[3][3];
clrscr();
printf("\n enter 9 values of d 1st array:");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
scanf("%d",&a[i][j]);
}
}
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
printf("\t %d",a[i][j]);
}
printf("\n");
}
printf("\n enter 9 values of d 2nd array :");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
scanf("%d",&b[i][j]);
}
}
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
printf("\t %d",b[i][j]);
}
printf("\n");
}
printf("\n the product of above 2 matrices are:");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
res[i][j]=0;
for(k=0;k<=2;k++)
{
res[i][j]+=a[i][k]*b[k][j];
}
}
}
for(i=0;i<=2;i++)
{
printf("\n");
for(j=0;j<=2;j++)
{
printf("\t %d",res[i][j]);
}
}
getch();
}
No comments:
Post a Comment