C++ Program to Multiply Two Matrix Using Multi-dimensional Arrays

Matrix multiplication in c language: c program to multiply matrices (two dimensional array), this program multiplies two matrices which will be entered by the user. Firstly user will enter the order of a matrix. If the entered orders of two matrix is such that they can't be multiplied then an error message is displayed on the screen. You have already studied the logic to multiply them in Mathematics. Matrices are frequently used while doing programming and are used to represent graph data structure, in solving system of linear equations and many more

Algorithm: Multiplication of two matrix

Rule: Multiplication of two matrix is only possible if first matrix has size m X n and other matrix has size n x r. Where m, n and r are any positive integer.

Multiplication of two matrices is defined as
Where 1 ≤ i ≤ m and 1 ≤ j ≤ n
For example: Suppose two matrix A and B of size of 2 x 2 and 2 x 3 respectively

Example: C++ Program to Multiply Two Matrix Using Multi-dimensional Arrays

Output

Enter rows and columns for first matrix: 2
2
Enter rows and columns for second matrix: 2
3
Enter elements of matrix 1
Enter element A11 : 1
Enter element A12 : 2
Enter element A21 : 3
Enter element A22 : 4
Enter elements of matrix 2
Enter element B11 : 5
Enter element B12 : 6
Enter element B13 : 7
Enter element B21 : 8
Enter element B22 : 9
Enter element B23 : 10
Product of entered matrices:-
21     24      27
47     54      61