logo CodeStepByStep logo


Language/Type: C++ return
Author: Marty Stepp (on 2016/06/19)

Write a function named daysInMonth that accepts a month (an integer between 1 and 12) as a parameter and returns the number of days in that month. For example, the call of daysInMonth(9) returns 30 because September has 30 days. You may assume that the month value passed is between 1 and 12 inclusive. Ignore leap years; assume that February always has 28 days.

Recall the following table of the number of days in each month:

Month 1 Jan 2 Feb 3 Mar 4 Apr 5 May 6 Jun 7 Jul 8 Aug 9 Sep 10 Oct 11 Nov 12 Dec
Days 31 28 31 30 31 30 31 31 30 31 30 31
Type your solution here:

This is a function problem. Write a C++ function as described. Do not write a complete program; just the function(s) above.

You must log in before you can solve this problem.

Log In

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.

© Marty Stepp, all rights reserved.