Consider a function that given a current hourminute time and
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.
Solution
#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;
}
