# Write a program to find the product of two matrices

## Source Code

#include<stdio.h>
#include<conio.h>
int main (int argc, char *argv[])
{
clrscr();
int m1[10][10];
int m2[10][10];
int p[10][10];
int i,j,k,r,c;
for(i=0;i<10;i++)
{
for(j=0;j<10;j++)
{
m1[i][j]=0;
m2[i][j]=0;
p[i][j]=0;
}
}
printf("\n Enter size of row and colomn:");
scanf("%d %d",&r,&c);
printf("\n Enter the two matrices: \n");
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
printf("Enter element %d %d of m1: ",(i+1),(j+1));
scanf("%d",&m1[i][j]);
printf("Enter element %d %d of m2: ",(j+1),(i+1));
scanf("%d",&m2[j][i]);
}
}
printf("\n The first matrix is: \n");
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
printf("%d ",m1[i][j]);
}
printf("\n");
}
printf("\n The second matrix is: \n");
for(i=0;i<c;i++)
{
for(j=0;j<r;j++)
{
printf("%d ",m2[i][j]);
}
printf("\n");
}
printf("\n Product of matrices is: \n");
for(i=0;i<r;i++)
{
for(j=0;j<r;j++)
{
for(k=0;k<c;k++)
{
p[i][j]+=m1[i][k]*m2[k][j];
}
printf("%d ",p[i][j]);
}
printf("\n");
}
getch();
}

Find More from our code collection
Armstrong number, binary number to a decimal number, bubble sort, decimal number to binary number, factorial of the given number factors, fibonacci numbers, HCF and LCM, matrix, mergesort, salary of the employee. palindrome, quadratic equation, star patterns, series etc. and much more...