Please read the requirements:
Write a C++ function, date, that will accept a date via a parameter in the month-day-year format, mmddyyyy, (e.g., 10262020 stands for the date October 26, 2020), and then will determine the corresponding month number, day, and year of that date, returning these three integer values to the calling function via arguments. An example of a call to the function date is shown in the following statement:
date (10262020, month, day, year);
This call to the function date would result in the number 10 being returned into month, the number 26 being returned into day, and the number 2020 being returned into year. Requirements:
• The function date should not contain any cin or cout statements
• You do not need to write a complete program.
• You do not need to include comments with your code.
void date(int date,int &month,int &day,int &year){
year = date % 10000;
date = date / 10000;
day = date % 100;
date =date / 100;
month = date;
}
Complete Program
#include <iostream>
using namespace std;
void date(int date,int &month,int &day,int
&year){
year = date % 10000;
date = date / 10000;
day = date % 100;
date =date / 100;
month = date;
}
int main()
{
int month,year,day;
date (10262020, month, day, year);
cout<<month<<" "<<day<<" "<<year<<endl;
return 0;
}
Get Answers For Free
Most questions answered within 1 hours.