#include <stdio.h>
int main() {
int a[10][10], b[10][10],
mult[10][10], r1, c1, r2, c2, i, j, k;
printf("Enter
Rows and Columns for First Matrix:\n");
scanf("%d%d",
&r1, &c1);
printf("\nEnter
Rows and Columns for Second Matrix:\n");
scanf("%d%d",&r2,
&c2);
while (c1!=r2) {
printf("\nWrong Input: Column of
First Matrix is Not Equal to Row of Second Matrix.\n\n");
printf("\nEnter Rows and Columns for First Matrix:\n");
scanf("%d%d", &r1,
&c1);
printf("\nEnter Rows and Columns for Second Matrix:\n");
scanf("%d%d",&r2,
&c2);
}
printf("\nEnter Elements of
Matrix 1:\n");
for(i=0; i<r1; ++i)
for(j=0; j<c1; ++j)
{
printf("Enter Element a%d%d:
",i+1,j+1);
scanf("%d",&a[i][j]);
}
printf("\nEnter Elements of
Matrix 2:\n");
for(i=0; i<r2; ++i)
for(j=0; j<c2; ++j)
{
printf("Enter Elements b%d%d:
",i+1,j+1);
scanf("%d",&b[i][j]);
}
for(i=0; i<r1; ++i)
for(j=0; j<c2; ++j)
{
mult[i][j]=0;
}
for(i=0; i<r1; ++i)
for(j=0; j<c2; ++j)
for(k=0; k<c1; ++k)
{
mult[i][j]+=a[i][k]*b[k][j];
}
printf("\nMatrix Multiplication
Result:\n\n");
for(i=0; i<r1; ++i)
for(j=0; j<c2; ++j)
{
printf("%d ",mult[i][j]);
if(j==c2-1)
printf("\n\n");
}
return 0;
}