Example 71: Product of Matrices
Learn how to calculate the product of two matrices.
We'll cover the following
Problem
Write a program to obtain the product of two 3 x 3 matrices.
The function takes in three 2-D arrays as parameters, where the first two arrays represent the original matrices, and in the third array, you need to store the multiplication result.
❗Note: For matrix multiplication, the number of columns of the first matrix and the number of rows of the second matrix should be equal; otherwise, the matrices cannot be multiplied.
Example
Input (Matrix 1, Matrix 2) | Output (Matrix 3) |
---|---|
1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 |
6 6 6 6 6 6 6 6 6 |
Demonstration
Get hands-on with 1400+ tech skills courses.