## C Program to Multiply Two Matrices Using Multidimensional Arrays

In this program, the user is asked to enter the elements of the two matrices a and b. Then the elements of these two matrices are multiplied and saved it in third matrix. Finally, the result (third matrix) is printed on the screen.

##### Source Code
``````#include<stdio.h>
void main()
{
int a[3][3], b[3][3], c[3][3], i, j, k;

printf("Enter 1st matrix\n");
for(i=0; i<3; i++)
{
for(j=0; j<3; j++)
{
scanf("%d", &a[i][j]);
}
}
printf("Enter 2nd matrix\n");
for(i=0; i<3; i++)
{
for(j=0; j<3; j++)
{
scanf("%d", &b[i][j]);
}
}

printf("\nMultiplication of A and B matrices is\n");
for(i=0; i<3; i++)
{
for(j=0; j<3; j++)
{
c[i][j] = 0;
for(k=0; k<3; k++)
{
c[i][j] = c[i][j] + a[i][k] * b[k][j];
}
printf("%d ", c[i][j]);
}
printf("\n");
}
getch();
}``````
##### Output
``````Enter 1st matrix
1 2 3
4 5 6
7 8 9
Enter 2nd matrix
2 2 2
3 3 3
4 4 4

Multiplication of A and B matrices is
20 20 20
47 47 47
74 74 74``````

"Coding Hub - Learn to code" app now available on Google Play Store