/*To find the Matrix multiplication*/
#include<stdio.h>
main ()
{
int i,j,k,m1,n1,m2,n2,sum=0;
int a[10][10],b[10][10],c[10][10];
printf("Enter the order of the first matrix A\n");
scanf("%d%d",&m1,&n1);
printf("Enter the elements of the first matrix A row-wise\n");
for(i=0;i<m1;i++)
for(j=0;j<n1;j++)
scanf("%d",&a[i][j]);
printf("Enter the order of the 2nd matrix B\n");
scanf("%d%d",&m2,&n2);
printf("Enter the elements of the 2nd matrix B row-wise\n");
for(i=0;i<m2;i++)
for(j=0;j<n2;j++)
scanf("%d",&b[i][j]);
if(n1==m2)
{
for(i=0;i<m1;i++)
{
for(j=0;j<n2;j++)
{
for(k=0;k<n1;k++)
sum=sum+a[i][k]*b[k][j];
c[i][j]=sum;
sum=0;
}
}
printf("The required matrix is\n");
for(i=0;i<m1;i++)
{
for(j=0;j<n2;j++)
printf("%d ",c[i][j]);
printf("\n");
}
}
else
printf("Matrix multiplication is not possible\n");
printf("\nThis program is written by Dr. Sourav Kar");
printf("\nPress any key to exit.\n");
}