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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started