// Reads a 2-D array from console input void read_matrix( double array[MAX_ROWS][MAX_COLS], int &rows, int &cols ) { cout << "Enter the number of rows and columns.\n" << "# of Rows = "; cin >> rows; cout << "# of Columns = "; cin >> cols; cout << endl; for ( int i = 0; i < rows; i++ ) { for ( int j = 0; j < cols; j++ ) { cout << "Entry [" << i << "][" << j << "] = "; cin >> array[i][j]; } } } // Prints a 2-D array to console output #include void prnt_matrix( double array[MAX_ROWS][MAX_COLS], int rows, int cols, short prt_width ) { cout << setiosflags( ios::left ); for ( int i = 0; i < rows; i++ ) { for ( int j = 0; j < cols; j++ ) { cout << setw( prt_width ) << array[i][j] << " "; } cout << "\n"; } } // Computes a linear combination of two 2-D arrays: // array3 = c1 * array1 + c2 * array2 void lin_comb( double array1[MAX_ROWS][MAX_COLS], double array2[MAX_ROWS][MAX_COLS], double array3[MAX_ROWS][MAX_COLS], double c1, double c2, int rows, int cols ) { for ( int i = 0; i < rows; i++ ) { for ( int j = 0; j < cols; j++ ) { array3[i][j] = c1 * array1[i][j] + c2 * array2[i][j]; } } }