Explore BrainMass
Share

# Matrix Multiplication Program Using Arrays

Attached are the requirements for the program.

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
*/

http://en.wikipedia.org/wiki/Matrix_multiplication
Your program should be like this:

/*
this program multilies two matrices
*/
#include <iostream>
/* 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

Dear friend,

As I could understand you are looking for a simple C++ function which allows you to multiply two matrices.
I would suggest you to write a template function which can work for other basic data types(like float, double and etc.)
However, I try to explain my function as ...

#### Solution Summary

A C++ function to multiply arrays is given.

\$2.19