73.5k views
5 votes
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

User ADvo
by
5.5k points

1 Answer

2 votes

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;

}

Step-by-step 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.

User Daniel Haviv
by
5.6k points