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

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!