Skip to content

luc084.c

Problem Statement

Define a function that compares two given dates. Return 0 if equal, otherwise return 1.

Metadata

Property Detail
Author Amit Dutta amitdutta4255@gmail.com
Date 08 Feb 2026
License MIT License (See the LICENSE file for details)

Actions

Raw View on GitHub

💡 You can print or save this file by opening Raw and using your browser.

Source Code

#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;
}