Add two time

Description

Get two time in hour and minutes and add them
Input:
6:03
4:59
Output:
11:02

Solution

#include<stdio.h>
struct time{
	int hour;
	int min;
};

int main()
{
	struct time t1,t2,t3;
	printf("Enter First time:");
	scanf("%d:%d",&t1.hour,&t1.min);
	printf("Enter second time:");
	scanf("%d:%d",&t2.hour,&t2.min);
	t3.hour=t1.hour+t2.hour;
	t3.min=t1.min+t2.min;
	if(t3.min>59)
	{
		t3.hour++;
		t3.min=t3.min-60;
	}
	printf("%d:%d",t3.hour,t3.min);
	return 0;
}

Explanation

t1,t2 and t3 are structure varibles, each occupies 8btyes. 4 bytes for hour and 4bytes for minutes.

Add minutes of t1 and t2 and store it in t3, then add hours of t1 and t2 and store it in t3.
if l3 minutes is greater than 59 then increment t3 time by and decrement t3 minutes by 60.