void build_Matrx ( double [][MAX], int &sizeRow, int &sizeCol ){
//int sizeRow,sizeCol;
double element;
double matrx1 [MAX][MAX];
cout << "Enter the number of rows you want in the first matrix." << endl;
cin >> sizeRow;
cout << "Enter the number of columns in the first matrix." << endl;
cin >> sizeCol;
for ( int i = 0; i < sizeRow; i++ )
{
for ( int j = 0; j < sizeCol; j++ )
{
cout << "Enter element " << i << "," << j << endl;
cin >> element;
matrx1 [i][j] = element;
}
}
}
void printMatrx ( double a [][MAX], int &b, int &c ){
for( int i = 0; i < b; i++)
{
for(int j = 0; j < c; j++)
{
cout << setw(6) << a [i][j];
if ( i == ( c - 1 ) )
cout << endl << endl;
}
}
}
//*******************MAIN*****************************************************
int main ()
{
double matrx1 [][MAX] = {0};
//double matrx2 [][MAX] = {0};
int sizeRow, sizeCol = 0;
build_Matrx ( matrx1, sizeRow, sizeCol );
cout << endl<< endl;
cout << sizeRow << sizeCol;
getch();
printMatrx( matrx1, sizeRow, sizeCol );
The output is:
Enter the number of rows you want in the first matrix.
2
Enter the number of columns in the first matrix.
2
Enter element 0,0
1
Enter element 0,1
2
Enter element 1,0
3
Enter element 1,1
4