luc084.c ​
Metadata ​
- Author — Amit Dutta
- Last updated — 08 Feb 2026
- License — MIT License (See the LICENSE file for details)
Problem Statement ​
Problem Statement
Define a function that compares two given dates. Return 0 if equal, otherwise return 1.
Source Code ​
Printing the code
To print this file, open it on GitHub and click Raw before printing, or use the Download Raw button above and print directly from that page.
c
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct date
{
int day;
int month;
int year;
};
int compare_dates(struct date d1, struct date d2);
int main()
{
struct date date1, date2;
printf("Enter Date 1 (dd mm yyyy): ");
scanf("%d %d %d", &date1.day, &date1.month, &date1.year);
printf("Enter Date 2 (dd mm yyyy): ");
scanf("%d %d %d", &date2.day, &date2.month, &date2.year);
if (compare_dates(date1, date2) == 0)
printf("The dates are Equal.\n");
else
printf("The dates are NOT Equal.\n");
return 0;
}
int compare_dates(struct date d1, struct date d2)
{
if (d1.day == d2.day && d1.month == d2.month && d1.year == d2.year)
return 0;
else
return 1;
}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
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