Question: Define a struct named Time having int h and m values representing hours and minutes. Write a function named difference that accepts two Times
Define a struct named Time having int h and m values representing hours and minutes. Write a function named difference that accepts two Times as parameters and returns their difference as Time. For instance, running the following code in the main function should print "1:50", "3:50", "0:35", "6:15". Time t1 = { 5,30 }; Time t2 = {7,20 }; Time t3 = {11,10 }; Time t4 = { 11,45 }; cout < < difference (t1, cout < < difference (t3, cout < < difference (t3, cout < < difference (t4, t2).h < < ":" < < difference (t1, t2).m < < endl; t2).h < < ":" < < difference(t3, t2).m < < endl; t4).h < < ":" < < difference(t3, t4).m < < endl; t1).h < < ":" < < difference (t4, t1).m < < endl;
Step by Step Solution
There are 3 Steps involved in it
Heres the implementation of the Time struct and the difference function cpp include iostream struct ... View full answer
Get step-by-step solutions from verified subject matter experts
