Explain step by step the next c++ source code for the problem shownbelow... The
ID: 3613696 • Letter: E
Question
Explain step by step the next c++ source code for the problem shownbelow...The problem is:
Use one variable to store three data:
Design a program that use data type:int,length:2 bytes variable “date” to store threevariable
“day”, “month”,and “year”.
(1). Input these three variable “day”,“month”, and “year” into variable“date”:
Hint: Design a formula converts the actual three data into thevariable “date”,
according to the format of the 2-byte integer variable“date” provided by yourself.
(2). Extract the three data from variable“date”
The source code is:
#include <iostream>
using namespace std;
int main()
{int i;
unsigned int date,month, day, year;
cout<<"Enter a month: ";
cin>>month;
cout<<"Enter a day: ";
cin>>day;
cout<<"Enter a year: ";
cin>>year;
month=month<<12;
day=day<<7;
date=month|day|(year-2000);
cout<<"The date is: ";
std::cout<<std::hex<<date<<endl;
month=date&0xf000;
month=month>>12;
day=date&0xf80;
day=day>>7;
year=date&0x7F;
std::cout<<std::dec;;
cout<<"The date is:"<<month<<"/"<<day<<"/"<<year+2000<<endl;
cout<<endl;
system("pause");
return 0;
}