Using C++

Complete the function definition to output the hours given minutes. Output for sample program:

3.5
Given Code

#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 :

Answer:

#include<iostream>

using namespace std;

void OutputMinutesAsHours(double origMinutes) { //Same as question

   double hours=origMinutes/60; //solution is here

   cout<<hours;

}

//Below is same as mentioned in question

int main() {

OutputMinutesAsHours(210.0);

cout << endl;

return 0;

}

OUTPUT :

3.5

Explanation:

In the above code, only two lines are added. To convert minutes into hours we have to divide them 60, so we take minutes as input and define a new variable of double type which stores minutes converted to hours and then that variable is printed to console. For 210, it gives 3.5, similarly for 3600 it gives 60 and so on.