Question: Requirements Write a function string get_date(int day) that will return a string indicating the month and day of the year based on an integer input.

Requirements

Write a function string get_date(int day) that will return a string indicating the month and day of the year based on an integer input. For this function to return a string that is a combination of a month (a string) and a day (an integer), you will have to use the to_string() function

string get_date(int day) { // more code here // to use to_string(), see the compiler requirements below  // to_string() is a library function  // you do not need to create it return months[month] + " " + to_string(day_of_month); } 

In the function, declare a string array as below

string months[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; 

In the function, declare an int array as below

int days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; 

In main, ask the user to enter an integer between 1 and 365

Display to the user the month and day by calling the get_date() function. (See interaction)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!