Header Ads Widget

C PROGRAM: Program that compares two input dates by using pointers. To store a data use a structure that contains three members namely date, month and year. If the dates are equal then display message as 'Equal' otherwise 'Unequal' in C language - Sparsh Blog

 Ans:->




The program that compares two input dates by using pointers. To store a data use a structure that contains three members namely date, month and year. If the dates are equal then display message as "Equal" otherwise "Unequal" in C language.


Program is as follows:--


#include<stdio.h>

struct date

{

        int day;

        int month;

        int year;

};

void main()

   {

        struct date d1,d2,*D1,*D2;

        D1=&d1;

        D2=&d2;

        printf("Enter the First date dd/mm/yyyy:");

        scanf("%d%d%d",&D1->day,&D1->month,&D1->year);

        printf("Enter the Second date dd/mm/yyyy:");

        scanf("%d%d%d",&D2->day,&D2->month,&D2->year);

        if((D1->day==D2->day)&&(D1->month==D2->month)&&(D1->year==D2->year))

        printf("EQUAL");

        else

        printf("UNEQUAL");

}


OUTPUT:-


Enter  the First date dd/mm/yyyy : 

12

06

2018

Enter the Second date dd/mm/yyyy

18

05

2020


UNEQUAL


THANKU FOR READING THIS ARTICLE ON-


If you want to suggest any changes in the program please feel free to contact us in the comment section or you can reach us using Contact us Page.


Post a Comment

0 Comments