Write a program to compare two given dates. To store a date uses a structure that contains three members namely day, month and year. If the dates are equal then display message equal otherwise unequal

 Code:-

#include<stdio.h>

struct data
{
int day,month,year;
}d1,d2;

int main()
{
printf(“Enter first daten”);
scanf(“%d%d%d”,&d1.day,&d1.month,&d1.year);
printf(“Enter the second daten”);
scanf(“%d%d%d”,&d2.day,&d2.month,&d2.year);
if(d1.day==d2.day && d1.month==d2.month && d1.year==d2.year)
printf(“Equaln”);
else
printf(“Unequal”);
return 0;
}

Output:-

Enter first date
12 3 2021
Enter the second date
12 3 2021

Equal



Leave a Reply

Your email address will not be published.