Program to Implement the Array Multiplications

There we will perform the multiplication of two matrix using c program. the multiplication can be perform if the first matrix columns is equals to the second matrix rows.

for example :
first matrix is:
2 2 3
3 2 2

second matrix is:
2 3
2 2
3 2

after multiplication
17 16
16 17

ALGORITHM:-

step 1 : Start
step 2 : Enter the first matrix size 
step 3 : Enter the elements of first matrix and store in 2D array
step 4 : Enter the second matrix size 
step 5 : Enter the elements of second matrix and store in 2D array
step 5 : Multiply the first matrix first row with second matrix first column
step 6 : Store the result in third array name is result
step 7 : Repeat the process 5,6
step 8 : Display the result array
step 9 : Exit
PROGRAM CODE:-

#include < stdio.h >
#include < conio.h >
void main()
{
    int m, n, p, q, i, j, k, sum = 0;
    int fmatrix[100][100], smatrix[100][100], result[100][100];

    printf("Enter the num of row and column in first matrixn");
    scanf("%d%d", &m, &n);
    printf("Enter first matrix elementn");
    for (i = 0; i < m; i++)
    {
        for (j = 0; j < n; j++)
        {
            scanf("%d", &fmatrix[i][j]);
        }
    }

    printf("Enter the num of row and column in second matrixn");
    scanf("%d%d", &p, &q);
    if (n != p)
    {
        printf("Multiplication cannot be perform.n");
    }
    else
    {
        printf("Enter second matrix elementn");
        for (i = 0; i < p; i++)
        {
            for (j = 0; j < q; j++)
            {
                scanf("%d", &smatrix[i][j]);
            }
        }
    }

    //Performing the multiplication of both matrix
    for (i = 0; i < m; i++) 
    {
        for (j = 0; j < q; j++) 
        {
            for (k = 0; k < p; k++) 
            {
                sum = sum + fmatrix[i][k]*smatrix[k][j];
            }
            result[i][j] = sum;
            sum = 0;
        }
    }

    printf("After multiplication of both matrix:-n");
    for (i = 0; i < m; i++) 
    {
        for (j = 0; j < q; j++)
        {
            printf("%dt", result[i][j]);
        }
        printf("n");
    }
}
OUTPUT:-
Enter the num. of row and column in first matrix:
2
2
Enter first matrix elements
2
5
1
2
Enter the num of row and column in second matrix:
2
2
Enter second matrix elements
1
2
6
5

after multiplication of both matrix
32  29
13  12
C Program to perform the multiplication of two matrix
Multiplication of two matrix
Matrix multiply using C Program
C program to perform the multiplication of two different arrays