### Help with Two Dimensional Arrays

Can anyone help with this program?

Write a program that creates and initializes two two-dimensional arrays 2 by 3 and 3 by 2. Using the concept of C++ for/while loop, multiple the two matrices together and display the new matrix. Make sure your program validates the rule above before multiplying the two matrices
What problems are you having with it? It seems pretty well-described.
Have a hard time getting started...
This is what i have so far...

#include <iostream>

using namespace std;

int main()
{
double array1[2],[3] =

double array2[3],[2] =

system("pause");
return 0;
}
Anything?
So far what i have...

#include <iostream>

using namespace std;

int main()
{
double array1[2][3] = {{45,20,54},
{30,25,35}};
double array2[3][2] = {{35,40},
{25,30},
{40,35}};
double array3[2][2];
for(int row2 = 0, row<2, ++row)
{
for(int col =0; col<3; ++col)
array1[row][col];
}

for(int row2 = 0; row2<3; ++row2)
{
for(int col2 = 0; col<2; ++col2)
array2[row2][col2];
}

for(int a = 0; a <

system("pause");
return 0;
}
Looks like you have declared and initialized the two arrays okay.

I recommend creating a routine that outputs the arrays, to confirm that the two arrays have, indeed, been assigned correctly. You are going to need this routine anyhow, to output the result of the matrix multiplication.

Also, I see two for loops in your present code; however, you don't do anything in them. And you seem to be using the pre-increment operator (e.g. - ++row). Are you sure you want to do that?

Hint: you are going to need three for loops.
Topic archived. No new replies allowed.