Today we will write a C++ program to multiply two matrices.

Example:

Two matrices A and B can only be multiplied when the number of columns in A is equal to the number of rows in B.

Matrix multiplication in C++

Also, the order of the resultant matrix is:

  • row = number of rows in A
  • col = number of columns in B

Considering all the criteria we can proceed for the multiplication of matrices.

We will need to nest 3 for loops in order to multiply and store the multiplication result into the resultant matrix.

Let’s see the C++ source code.

output

If you have any doubts or suggestion then please comment below.

Leave a Reply