Question
A. Write a function that finds the sum of the values of a particular column in a 2-D array of integers. Assume the 2-D array
A. Write a function that finds the sum of the values of a particular column in a 2-D array of integers. Assume the 2-D array is rectangular (each row has the same number of elements). For example, if array = { {1,2,3), (4,5,6), {7,8,9} } then columnSum (array, 3, 0) should return 12 (1+4+7).
/* Returns the sum of the elements at column index col. * NUM_COLS: the number of columns in the 2-D array * * numRows: the number of rows in the 2-D array * col: the index of the column to be summed */ int columnSum (int array[] [NUM COLS], int numRows, int col)
//your code here
B.
Write a function to find the largest column-sum (NOT the index of the largest column-sum). Be sure to make use of the columnsum function you wrote in part A. For example, if array = ((1,2,3), (4,5,6),(7,8,9) ) then largestcolumsum (array, 3) should return 18 (3+6+9).
/* Returns the largest column-sum. * NUM_COLS: the number of columns in the 2-D array * numRows: the number of rows in the 2-D array */ int largestColumnSum (int array [][NUM_COLS], int numRows) {
// your code here
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