Write a program that creates a 2D array initialized with test data. Use any data
ID: 3650265 • Letter: W
Question
Write a program that creates a 2D array initialized with test data. Use any data type you wish. The program should have the following functions:1. getTotal Accepts a 2d array as its argument and returns the total of all the values in the array
2. getAverage Accepts a 2d array as its argument and returns the average of all the values in the array
3. getRowTotal Accepts a 2D array as its first argument and an integer as its second argument. The second argument should be a subscript of a row in the array. The function should return the total of the values in the specified row.
1. getColumnTotal Accepts a 2D array as its first argument and an integer as its second argument. The second argument should be a subscript of a column in the array. The function should return the total of the values in the specified column.
2. getHighestInRow Accepts a 2D array as its first argument and an integer as its second argument. The second argument should be a subscript of a row in the array. The function should return the highest value in the specified row.
3. GetLowestInRow Accepts a 2D array as its first argument and an integer as its second argument. The second argument should be a subscript of a column in the array. The function should return the highest value in the specified column.
Explanation / Answer
This should help a little: int getRowTotal(int** twoDimArray, int rowIndex, int width) { ....int total = 0; ....for (int i = 0; i != width; ++i) ........total += twoDimArray[rowIndex][i]; .... ....return total; }
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.