Question #234493

Write a program that compares two given dates. To store date use structure say date that
contains three members namely date, month and year. If the dates are equal then display message
as "Equal" otherwise "Unequal". Create a user defined function Compare_Date() to do so which
takes pointer to structure as input.

Expert's answer

#include <iostream>


using namespace std;


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


int main()
{
    cout<<"Enter first date\n";
    cin>>d1.day>>d1.month>>d1.year;
    
    cout<<"\nEnter the second date\n";
    cin>>d2.day>>d2.month>>d2.year;
    
    if(d1.day==d2.day && d1.month==d2.month && d1.year==d2.year)
     cout<<"\nEqual";
    else
     cout<<"\nUnequal";
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS