Create a program to multiply two matrices


Discuss the below:

Q: You are going to write a program to multiply two matrices.

The matrices are stored in a two-dimensional array:

int[][] matrixA

int[][] matrixB

Recall:

Here is the way to declare a two-dimensional array:

int testArray[3][4] = {{1,2,3,4},{2,3,4,1},{5,4,3,0}}; // three rows, four columns
/*
after declaration, testArray will be like:
1 2 3 4
2 3 4 1
5 4 3 0
*/

This link may help you recall how to multiply two matrices

https://en.wikipedia.org/wiki/Matrix_multiplication

Your program should be like this:

/*
this program multilies two matrices
*/
#include
/* include other libs */

using namespace std;

int main()
{
/* step1: declare three arrays here:
matrixA (3*4), 3 rows, 4 columns
matrixB (4*3),
and result (3*3)
*/

/* step2: compute the result */

/* step3: output the result */
}

The values of matrices in your program can be hard-coded and any numbers you like(including the numbers of columns/rows and the values of matrices), which means you do not have to ask user to input those numbers. Of course you can do this if you would like to.

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Create a program to multiply two matrices
Reference No:- TGS01937490

Now Priced at $25 (50% Discount)

Recommended (98%)

Rated (4.3/5)