Previous Next
0 / 13
Module DEMO-32-56DEMO-C-32

Days in Month Calculator

DEMO-C-32 โ€ข Programming in C

Browser-only practice

Problem Statement

Write a program in C to read any Month Number in integer and display the number of days for this month.

The months are numbered from 1 to 12, where:

  • 1 = January
  • 2 = February
  • 3 = March
  • 4 = April
  • 5 = May
  • 6 = June
  • 7 = July
  • 8 = August
  • 9 = September
  • 10 = October
  • 11 = November
  • 12 = December

For this exercise, assume February has 28 days (non-leap year).

Example: If the input is 7 (July), the output should be "Month have 31 days".

Constraints

The input must be an integer between 1 and 12 (inclusive).

Input Format

A single integer representing the month number (1-12).

Output Format

A single line containing the text "Month have X days" where X is the number of days in that month.

Sample Testcases

Submit runs every public testcase in this browser. Results and code never leave this device.

Sample #1
Public sample
7
Month have 31 days
July is the 7th month and has 31 days.
Sample #2
Public sample
2
Month have 28 days
February has 28 days in a non-leap year.
Sample #3
Public sample
4
Month have 30 days
April is the 4th month and has 30 days.
Sample #4
Public sample
11
Month have 30 days
November is the 11th month and has 30 days.
Sample #5
Public sample
13
Invalid month
Month 13 is invalid.

Web terminal

C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.

Saved in this browser
Editor settings