-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathq9.c
61 lines (55 loc) · 959 Bytes
/
q9.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include<stdio.h>
#include<string.h>
typedef struct time{
int hour;
int minut;
int second;
}time;
void display(time t){
printf("Time is %d:%d:%d\n\n",t.hour,t.minut,t.second);
}
int timecmp(time t1,time t2){
if (t1.hour>t2.hour)
{
return 1;
}
if (t1.hour<t2.hour)
{
return -1;
}
// decision on the basis of minuts
if (t1.minut>t2.minut)
{
return 1;
}
if (t1.minut<t2.minut)
{
return -1;
}
// Decision basis of seconds
if (t1.second>t2.second)
{
return 1;
}
if (t1.second<t1.second)
{
return -1;
}
return 0;
}
int main(){
time t1 = {5,45,34};
time t2 = {3,30,45};
display(t1);
display(t2);
int com = timecmp(t1,t2);
if (com=1)
{
printf("Time 1 is bigger\n");
}
else
{
printf("Time 2 is bigger\n\n");
}
return 0;
}