im having problems with my program that needs to have the user input 2 birthdates and then determine which one is older im not to sure where to go from what i have
i fixed my program a bit but now all it does is output what i input minus the first 0 how do i get it to sort between the 2 to decide which one is older
#include <iostream>
#include <math.h>
usingnamespace std;
struct printDate
{
printDate (int dd, int mm, int yyyy):
day(dd),month(mm),year(yyyy){}
int day;
int month;
int year;
};
struct getDate
{ getDate( int dd, int mm, int yyyy):
day(dd),month(mm),year(yyyy){}
}
int main()
{
int date1;
int date2;
cout << "Please enter your birthdate" << endl;
cin >> getDate >> date1;
cout << "Please enter the birthdate of someone else" << endl;
cin >> getDate >> date2;
cout << "Your birthday is " << (date1) << endl;
cout << "Your friends birthday is " << (date2) << endl;
if (date1> date2)
cout << "You are older then your friend" << endl;
else
cout << "Your friend is older then you" << endl;
return 0;
}
Compare the years. The lesser is older. If they are equal, compare the months. The lesser is older. If they are equal, compare the day. The lesser is older.
That's how the human brain does it too, we just take it for granted. You have to "tell" your computer those steps. ;)