Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PLease I need some help. I nedd to write a code in C++. Write two functions, tot

ID: 3934892 • Letter: P

Question

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.

Explanation / Answer

#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;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote