Exercises   Set-3

1. Provide the missing function definitions in the following program:

#include<iostream>

struct Bday {
   int year; //Year, month and date  of birth
   int month;
   int date;
} ;

struct Person {
   double ID;
   Bday Date;
};

void getInfo(Person&);
void printInfo(Person&);

int main() {
  Person alice, joe;
  getInfo(alice); //Prompt and get information about this person from user
  getInfo(joe);   //Prompt and get information about this person from user
  printInfo(alice); //Print info about this person
  printInfo(joe);   //Print info about this person
}


/** Output format ******************

ID:-> 00012
Date of Birth:-> 9/12/1971


ID:-> 00119
Date of Birth:->10/1/1981

************************************/

Note: If alice is of type Person, then alice.Date.year refers to the value of year in the Person object named alice.

2. Modify the above program to include a function comparePerson(Person* p1, Person* p2) that returns an integer indicating whether (i) p1 and p2 are born on the same day (ii) If p1 is older than p2 or (iii) if p2 is older than p1. Use this function to get input from user about two people as in the previous program, and prints out a message about who is older.