jmizza
New Coder
Hi, so I'm trying to write a program that takes two square matrices of any size, multiplies them, and output the product using dynamic arrays for an assignment. I'm not having any errors but I'm not getting the correct product matrix. This is the code for my loop:
And this is the result I'm getting:
Code:
for(int row = 0; row < r; row++)
{
int col;
for (col = 0; col < s; col++)
{
E[row][col] += C[row][col] * D[col][row];
}
}
And this is the result I'm getting:
Code:
Enter the dimensions of your matrices: 3 3
Enter the values of your first matrix: 1 2 3 4 5 6 7 8 9
Enter the values of your second matrix: 1 2 3 4 5 6 7 8 9
The product of:
1 2 3
4 5 6
7 8 9
and:
1 2 3
4 5 6
7 8 9
is:
1 8 21
8 25 48
21 48 81