Alright, so I am trying to create a program that will take a [m][n] Matrix and multiply it by a [n][p] Matrix, filling each matrix with increasing values.
I am having a problem with my function, prototype, and call. I keep getting the "...not declared in this scope" error and know it has to do with the syntax I used for my function.
Below is my code. Can anyone please help me?
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
//int multiply(int[][acol],int[][bcol]);
// void menu();
int main ()
{
int row(0), column(0);
int arow(0),acol(0), brow(0),bcol(0);
int matrix_a[arow][acol];
int matrix_b[brow][bcol];
int i(0), j(0);
int temp(0),value(0);
cout << "Please Enter the row dimension for Matrix A" << endl;
cin >> arow;
cout << "Please enter the column dimension for Matrix A" << endl;
cin >> acol;
cout << "Your matrix is: " << arow << " by " << acol << endl;
for(i = 0; i < arow; i++)
for(j = 0; j < acol; j++)
{
++value;
matrix_a[i][j] = value;
cout << "The values for Matrix A are: " << matrix_a[i][j] << endl;
}
cout << "Please enter the row dimension for Matrix B.\n" << "Note: it must equal the column dimension of A" << endl;
cin >> brow;
if ( brow != acol)
{
cout << "Matrix multiplication requires inner dimensions of the matrices to be equal" << endl;
cout << "Program exiting" << endl;
return (0);
}
cout << "Please enter the column dimension for Matrix B" << endl;
cin >> bcol;
cout << "Your matrix is: " << brow << " by " << bcol << endl;
for(i = 0; i < brow; i++)
for(j = 0; j < bcol; j++)
{
++temp;
matrix_b[i][j] = temp;
cout << "The values for Matrix B are: " << matrix_b[i][j] << endl;
}
// multiply(matrix_a,matrix_b);
return 0;
}
/*
int multiply(int a[][], int b[][])
{
int i, j, k, result = 0;
double sum, total = 0.0;
for (i = 0; i < arow; i++)
for (j = 0; j < bcol; j++)
{
sum = 0;
for (k = 0; k < brow; k++)
total = 0;
total = a[i][k]*b[k][j];
sum = sum + total;
}
result[i][j] = sum;
return result;
}
*/
Thank you for your time!