Complete the function definition to output the hours given minutes. Output for sample program: 3.5
#include
using namespace std;

void OutputMinutesAsHours(double origMinutes) {

/* Your solution goes here */

}

int main() {

OutputMinutesAsHours(210.0); // Will be run with 210.0, 3600.0, and 0.0.
cout << endl;

return 0;
}

Respuesta :

#include <iostream>

using namespace std;


void OutputMinutesAsHours(double origMinutes) {

double hours = origMinutes / 60.0;

cout << hours;

}


int main() {

OutputMinutesAsHours(210.0); // Will be run with 210.0, 3600.0, and 0.0.

cout << endl;

return 0;

}


In bold style, you can see the lines of code added to get the hours given in minutes. As there are 60 minutes in an hour; therefore, to convert minutes to hours, you have to divide the given minutes to 60.0. I have used the datatype "double", as the parameter origMinutes of the given function OutputMinutesAsHours is in double. Just run the above code in any of the C++ Compiler, you have get the answer 3.5.