Menu Close

Find the time differences in the two different time zones 

Hassan lives in a village and has to take the bus to college every day.  Hassan is in his final year studying Computer Science Engineering.  He had a great passion for the watch when he was a child. 

It was his childhood to buy a watch at festivals in his hometown. His dad buys him a new smartwatch. In it, he develops an application to find the time differences in the two different time zones. 

Can you help him?

Input:
First line integer A, B denoting hours of two different zone.
Second line integer C, D denoting the minutes of the different zone.
Third line E, F denoting the seconds of the different zone.

Output: 
First-line the difference between Hours, 
The second line  the difference between Minutes
Third line the difference between the seconds
#include <stdio.h>
union Time
{
  int hours,minutes,seconds;
};
int main()
{
    union Time startTime,stopTime,diff;
    scanf("%d%d",&startTime.hours,&stopTime.hours);
    diff.hours=startTime.hours - stopTime.hours;
    printf("%d\n",diff.hours);
    scanf("%d%d",&startTime.minutes,&stopTime.minutes);
    diff.minutes=startTime.minutes - stopTime.minutes;
    printf("%d\n",diff.minutes);
    scanf("%d%d",&startTime.seconds,&stopTime.seconds);
    diff.seconds=startTime.seconds - stopTime.seconds;
    printf("%d\n",diff.seconds);

	return 0;
}

INPUT_1:
20  14
15  10
10  08

OUTPUT:
6
5
2


INPUT_2:
18  9
19  10
15  08

OUTPUT:
9
9
7


ILLUSTRATION example

Executed using gcc in terminal linux

Morae Q!