Question: Please correct the code below /* Question Type : Write a function definition Write the needed code to make the program runs correctly. Implement the

Please correct the code below

/* Question Type : Write a function definition Write the needed code to make the program runs correctly.

Implement the function MinRow that is called from the main function. The function returns the index of the row that has the minimum total of its elements.

Hint: find the total of each row and find the minimum total, then return the index.

The sample runs are as follows.

Sample Run 1:

Enter rows and columns of the array: 4 4 4:4

1 1 1 1 2 1 1 1 0 1 1 1 2 2 2 1 1:1:1:1: 2:1:1:1: 0:1:1:1: 2:2:2:1: Row with min total is 2

Sample Run 2:

Enter rows and columns of the array: 3 3 3:3

0 1 0 1 1 0 2 2 2 0:1:0: 1:1:0: 2:2:2: Row with min total is 0

----------------------------------------------------------------------*/

#include #include using namespace std; const int MAXR = 100; const int MAXC = 100;

//-------------------------------------------------------------------- // Write your code starting after this line //--------------------------------------------------------------------

//---------------------------------------------------------------------- // You are not allowed to change any of the lines below this // comment //----------------------------------------------------------------------

void PrintArray(int a[][MAXC], int r, int c){ for (int i=0;i> a[i][j]; } } int main() { int r,c; int arr[MAXR][MAXC]; cerr << "Enter rows and columns of the array: "; cin >> r >> c; cerr << r << ":" << c << endl; cerr << endl; ReadArray(arr,r,c); PrintArray(arr,r,c); cout << "Row with min total is " << MinRow(arr,r,c) << endl; return 0; }

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!