Skip to main content

Posts

Showing posts with the label Program to compare dates

Sample C Program To Compare Two Dates Using Structures.

In this program user enters two dates for comparison. In order to store date we will use structure say date that contains three members namely date, month and year. If the dates are equal then display message as “Dates are Same." otherwise “Both the dates are different”.  void main() {     int i, f = 0;     struct date       {          int date;          int month;          int year;       };     struct date d[2];     for(i = 0; i < 2; i++)       {          printf("\n Enter day for the %d date \n", i + 1);          scanf("%d",&d[i].date);          printf("\n Enter the month for the %d) date \n", i + 1);          scanf("%d",&d[i].month);          printf("\n Enter the ye...