Write a program that returns the parity of the sum of the date, month and year of your birthday. If the sum is even, then we call it as even parity. Otherwise, it is odd parity. Example: Input: 12/8/1996 Output: Even

Respuesta :

ijeggs

Answer:

#include <iostream>

using namespace std;

int main()

{

   int birthDay,birthMonth, birthYear;

   cout << "Enter your Date of Birth: Day, Month and Year" << endl;

   cin>> birthDay;

   cin>>birthMonth;

   cin>>birthYear;

   cout<<"Your Birth Date is ";

   cout<< birthDay;

   cout<<"/";

   cout<<birthMonth;

   cout<<"/";

   cout<<birthYear<<endl;

   if((birthDay+birthMonth+birthYear)%2 ==0){

       cout<<"Even"<<endl;

   }

   else

       cout<<"Odd"<<endl;

   return 0;

}

Explanation:

Using the C++ Language we receive the users' input for the day, month and year of birth. using a series of cout statements we first print out the Birth date in the format 12/8/1996 . We then use an if statement with the modulo operator to check if the sume of day, month and year are even.

ACCESS MORE