Write a C++ function using the struct and function given.
struct time
{
int hrs;
int min;
int sec;
};
struct time calculateDifference(struct time t1, struct timet2){
struct time diff;
// Write your code here
return diff;
}
Sample inputs/outputs Below are some examples: Stop time t1 10:59:59 10:59:59 6:23:54 6:20:51 8:20:51 Start time t2 9:59:59 8:0:0 2:43:12 1:43:12 7:0:0 Time difference 1:0:0 2:59:59 3:40:42 4:37:39 1:20:51
For example, suppose we have initialized the structure variable t1 and t2 with the following values: struct time t1 {10,59,59}; struct time t2 = {9,59,59}; Then the call calculateDifference(t1, t2) should return the following values: {1,0,0} = Note: • The function calculateDifference ( ) takes two parameters of type time in its input parameters and returns the parameter of type time in the output. • Input time will be given in a valid format.
Write a C++ function using the struct and function given. struct time { int hrs; int min; int sec; }; struct time calcul
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am