Question: Two-dimensional arrays and functions Write the code CIS22A-HW7-XXXXX.cpp to create and print a 12 x 12 multiplication table using a 2-dimensional array and functions with

Two-dimensional arrays and functions

Write the code CIS22A-HW7-XXXXX.cpp to create and print a 12 x 12 multiplication table using a 2-dimensional array and functions with nested loops.

Define the following Global Constants at the top, before main function:

const int ROW_SIZE = 12;

const int COL_SIZE = 12;

const int WIDTH = 4;

Two required functions are:

void createTable(int [][COL_SIZE], int rows);

void printTable(int [][COL_SIZE], int rows);

Use this main code without any change:

int main()

{

int table[ROW_SIZE] [COL_SIZE];

createTable(table, ROW_SIZE);

printTable(table, ROW_SIZE);

return 0;

}

Suggestion:

- Do not use any other constant beside the above 3 global constants.

- In createTable() function, use nested "for" loops to fill the table with products of numbers. There is no output (cout) in this function.

- In printTable() function, use a separate simple loop to print the column header (1, 2, 3,.....) first.

Then use nested "for" loops to print the numbers from the table.

Use setw() with the WIDTH constant to align the numbers nicely.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!