previous | start | next

## Two-Dimensional Arrays

When passing a two-dimensional array to a function, you must specify the number of columns as a constant with the parameter type.

The number of rows can be variable.

>     void print_table(const double table[][BALANCE_COLS], int table_rows)
>     {
>        const int WIDTH = 10;
>        cout << fixed << setprecision(2);
>        for (int i = 0; i < table_rows; i++)
>        {
>           for (int j = 0; j < BALANCES_COLS; j++)
>              cout << setw(WIDTH) << table[i][j];
>           cout << "\n";
>        }
>     }

previous | start | next