Objective
- Program with multiple-subscripted arrays
Preparation
- Read Chapter 7 from Starting Out with C++ by Gattis.
- Print and complest Worksheet #13.
Programming
- Write a function called readArray that accepts two parameters; a two dimensional array of integers with a column size of six and an integer specifiying the number of rows of the array. It reads from the user a sequence of integer values and loads them into the array.
- Write a function, printArray, that receives a two dimensional array of integers with a column size of six and an integer indicating the number of rows in the array. It prints all the integers in the array row by row. All integers in a row should be printed on the same line, each in 5 spaces. Each row of the array should be printed on its own line.
- Write a function called printTotals that accepts the same two dimensional array of integers and an integer specifying the number of rows. It calculates and prints the total of each of the columns of the array. The totals should all be printed on one line, each in 5 spaces.
- Write prototypes for the functions printArray, readArray, and printTotals.
- Write a driver program that utilizes/demonstrates your functions. The driver program should create a two dimensional array of integers with five rows and six columns. It should allow the user to input values into the array by calling readArray. Then it should print the contents of the array by calling printArray. Finally it should print the totals of each column of the array by calling printTotals. Be sure to document the functions correctly by including complete specifications with the definitions. The output of your program should be formatted to look like the following example:
25 14 55 234 4 88
200 5 44 22 99 6
.
.
.
------------------------------
456 98 155 567 210 345
- Verify the program works correctly.
- Print the Grade Sheet. Show your program to the instructor.
|