-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathq8.c
55 lines (50 loc) · 966 Bytes
/
q8.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
#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\n ",d.date,d.month,d.year);
}
int datecmp(date d1, date d2){
// make decision on the basis of year comparision
if (d1.year>d2.year)
{
return 1;
}
if (d1.year<d2.year)
{
return -1;
}
// make decision on the basis of month comparision
if (d1.month>d2.month)
{
return 1;
}
if (d1.month<d2.month)
{
return -1;
}
// make decision on the basis of date comparision
if (d1.date>d2.date)
{
return 1;
}
if (d1.date<d2.date)
{
return -1;
}
return 0;
}
int main(){
printf("\n\n\n");
date d = {2,11,2020};
date d2 = {5,4,2022};
display(d);
display(d2);
int a = datecmp(d,d2);
printf("Date comparision function returns : \n %d\n\n",a);
return 0;
}