#include <stdio.h>
typedef struct time{
int hour;
int minute;
int second;
}timestruct;
void display(timestruct t1,timestruct t2)
{
printf("First time is:%d:%d:%d\n",t1.hour,t1.minute,t1.second);
printf("Second time is:%d:%d:%d\n",t2.hour,t2.minute,t2.second);
}
int timecomp(timestruct time1, timestruct time2)
{
if (time1.hour>time2.hour)
{
return 1;
}
if(time1.hour<time2.hour)
{
return -1;
}
if (time1.minute>time2.minute)
{
return 1;
}
if(time1.minute<time2.minute)
{
return -1;
}
if (time1.second>time2.second)
{
return 1;
}
if(time1.second<time2.second)
{
return -1;
}
return 0;
}
int main()
{
timestruct time1={12,02,34};
timestruct time2={12,02,34};
display(time1,time2);
int a=timecomp(time1,time2);
if (a==0)
{
printf("Both times are same\n");
}
else
{
printf("The times are not same\n");
}
return 0;
}