#include<stdio.h>
#include<conio.h>
void main()
{
long int a[50][50],b[50][50],c[50][50];
int i,j,k,r1,c1,r2,c2;
clrscr();
printf("\n Enter the order of Ist Matrix:");
scanf("%d%d",&r1,&c1);
printf("\n Enter the order of IInd Matrix:");
scanf("%d%d",&r2,&c2);
if(c1==r2)
{
printf("\n Enter the values for Ist Matrix:");
for(i=0;i<r1;i++)
for(j=0;j<c1;j++)
{
scanf("%ld",&a[i][j]);
}
printf("\n Enter the values for IInd Matrix:");
for(i=0;i<r2;i++)
for(j=0;j<c2;j++)
{
scanf("%ld",&b[i][j]);
}
for(i=0;i<r1;i++)
for(j=0;j<c2;j++)
{
c[i][j]=0;
}
for(i=0;i<r1;i++)
for(j=0;j<c2;j++)
for(k=0;k<c1;k++)
{
c[i][j]=c[i][j]+a[i][k]*b[k][j];
}
printf("\n the Ist Matrix: \n");
for(i=0;i<r1;i++)
{
for(j=0;j<c1;j++)
{
printf("\t %ld",a[i][j]);
}
printf("\n");
}
printf("\n the IIst Matrix: \n");
for(i=0;i<r2;i++)
{
for(j=0;j<c2;j++)
{
printf("\t %ld",b[i][j]);
}
printf("\n");
}
printf("\n the Multiplication of Ist & IInd Matrix is : \n");
for(i=0;i<r1;i++)
{
for(j=0;j<c2;j++)
{
printf("\t %ld",c[i][j]);
}
printf("\n");
} }
else
{
printf("\n Multiplication does not exist");
}
getch();
}
0 comments: (+add yours?)
Post a Comment