#include
int main()
{
int m, n, p, q, c, d, k, sum = 0;
int mat1[10][10], mat2[10][10], mat3[10][10];
printf(âEnter number of rows and columns of mat1 matrix\nâ);
scanf(â%d%dâ, &m, &n);
printf(âEnter elements of matrix 1\nâ);
for (c = 0; c < m; c++)
for (d = 0; d < n; d++)
scanf(â%dâ, &mat1[c][d]);
printf(â\nEnter number of rows and columns of mat2 matrix\nâ);
scanf(â%d%dâ, &p, &q);
if (n != p)
printf(â\nThe matrices canât be multiplied with each other.\nâ);
else
{
printf(â\nEnter elements of matrix2\nâ);
for (c = 0; c < p; c++)
for (d = 0; d < q; d++)
scanf(â%dâ, &mat2[c][d]);
for (c = 0; c < m; c++) {
for (d = 0; d < q; d++) {
for (k = 0; k < p; k++) {
sum = sum + mat1[c][k]*mat2[k][d];
}
mat3[c][d] = sum;
sum = 0;
}
}
printf(â\nProduct of the matrices:\nâ);
for (c = 0; c < m; c++) {
for (d = 0; d < q; d++)
printf(â%d\tâ, mat3[c][d]);
printf(â\nâ);
}
}
return 0;
}