logo CodeStepByStep logo

max_row

Author: Allison Obourn (on 2020/09/14)

Write a function named max_row that accepts a number of rows and columns, and a 2-D array of integers, as parameters and that returns the index of the row where the elements add up to the greatest value. For example:

int list[4][3] = {
    {  3,   8,  12},
    {  2,   9,  17},
    { 43,  -8,  46},
    {203,  14,  97}
};

Then the call of max_row(list, 4, 3) should return 3. If there is a tie between two or more rows, return the row with the smaller index.

Your code should work for an array of any size at least 1x1.

Function: Write a C function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.