Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

ISBN: 0132742926, 978-0132742924

More Books

Students also viewed these Databases questions

Question

How would you assess the value of an approach like this?

Answered: 1 week ago

Question

What are the stages of project management? Write it in items.

Answered: 1 week ago