← Back to If Statements
Question 250
Days In The Month
Days In The Month
Read a month number (1 to 12) and a year and print how many days that month has in the form Days: <count>. April, June, September and November have 30 days; February has 29 in a leap year and 28 otherwise, where a leap year is divisible by 4 but not by 100, or divisible by 400 (use the remainder operator %); every other month has 31. Input: two lines, the month then the year, each an integer, no prompts. Output: one line.
Expected Output:
Days: 29= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
If StatementsOperators
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.