Write a function called getRowTotal. This function should accept a two-dimensional int array as its first parameter (the array has 5 columns) and an integer as its second parameter. The second parameter should be the subscript of a row in the array. The function should return the total of the values in the specified row. Only write the function no need to write the main function

Respuesta :

Answer:

The solution is implemented using C++

int getRowTotal(int a[][5], int row) {

  int sum = 0;

  for(int i =0;i<5;i++)

  {

      sum += a[row][i];

  }

  return sum;

}

Explanation:

This defines the getRow function and the parameters are arr (the 2 d array) and row and integer variable

int getRowTotal(int arr[][5], int row) {

This defines and initializes sum to 0

  int sum = 0;

This iterates through the row and adds the row items

  for(int i =0;i<5;i++)    {

      sum += arr[row][i];

  }

This returns the calculated sum

  return sum;

}