-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path09_11_pr_09.c
48 lines (42 loc) · 892 Bytes
/
09_11_pr_09.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
#include<stdio.h>
typedef struct date{
int date;
int month;
int year;
}date;
void display(date d){
printf("The date is: %d/%d/%d\n", d.date, d.month, d.year);
}
int dateCmp(date d1, date d2){
// Make decision on the basis of Year comparison
if(d1.year>d2.year){
return 1;
}
if(d1.year<d2.year){
return -1;
}
// Make decision on the basis of Month comparison
if(d1.month>d2.month){
return 1;
}
if(d1.month<d2.month) {
return -1;
}
// Make decision on the basis of Date comparison
if(d1.date>d2.date){
return 1;
}
if(d1.date<d2.date) {
return -1;
}
return 0;
}
int main(){
date d1 = {5, 11, 31};
date d2 = {5, 11, 31};
display(d1);
display(d2);
int a = dateCmp(d1, d2);
printf("Date Comparison function returns: %d", a);
return 0;
}