#include<stdio.h>
#include<conio.h>
struct dmy
{
int date;
int month;
int year;
};
int datcmp(struct dmy a, struct dmy b)
{
if (a.date == b.date && a.month == b.month && a.year == b.year)
return 0;
else
return 1;
}
int main()
{
struct dmy a, b;
int flag;
printf("\nEnter the first date (dd mm yyyy) : ");
scanf("%d%d%d", &a.date, &a.month, &a.year);
printf("\nEnter the second date (dd mm yyyy) : ");
scanf("%d%d%d", &b.date, &b.month, &b.year);
flag = datcmp(a, b);
if (flag)
printf("\nThe dates are not same\n");
else
printf("\nThe dates are same\n");
_getch();
return 0;
}
Ad
Chapter - 11: Structures
Write a program that compares two given dates. To store date use structure say the date that contains three members namely date, month and year. If the dates are equal then display the message as "Equal" otherwise "Unequal".
Ad
Ad