PLease I need some help I nedd to write a code in C Write tw
PLease I need some help. I nedd to write a code in C++.
Write two functions, total_minutes() takes two integer parameters, a time in hours and minutes, and returns the total number of minutes, so total_minutes(2, 15) returns 135. The second function hours_minutes() takes three parameters, the first is a value parameter that is a time in minutes, the second two are reference parameters that will be set to the number of whole hours and remaining minutes in the first parameter, so for example hours_minutes(135, h, m) will set h to 2 and m to 15.
Solution
#include <iostream>
using namespace std;
// function declaration
void hours_minutes(int total,int &h, int &m);
int total_minutes(int h, int m);
int main () {
int h = 2;
int m = 15;
cout << \"total minutes \" << total_minutes(h,m) << endl;
hours_minutes(260,h,m);
cout << \"hours :\" << h << endl;
cout << \"minutes :\" << m << endl;
return 0;
}
void hours_minutes(int total,int &h, int &m) {
h= total/60;
m=total%60;
return;
}
int total_minutes(int h, int m){
return 60*h+m;
}
