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

Consider a function that, given a current hour-minute time and a number of minut

ID: 3925606 • Letter: C

Question

Consider a function that, given a current hour-minute time and a number of minutes, prints the time after that number of minutes has elapsed. Write this function, using the following prototype: void addTime(int curHour, int curMin, int mins); Your program should work for all times, though you may assume mins>0. All times are 24 hour time (e.g., 1^30 PM would be represented as 13:30). Consider the above problem again. This time, you wish to communicate the updated hour-min time back to the caller, instead of printing it. Write an appropriate prototype for this function. You do not need to write the function itself.

Explanation / Answer

#include <iostream>
using namespace std;

void addTime(int curHour, int curMin, int mins)
{
curMins += mins;
if(curMins >= 60)
{
curHour += curMins / 60;
curMins = curMins % 60;
}
if(curHours >= 24)
curHours = curHours % 24;
cout<<"Updated time is: "<<curHours<<" : "<<curMins<<endl;

}

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