Question
Determine the number of days in a month from the year 2021. You have to write a complete C program Program requirements: 1. Declare an
Determine the number of days in a month from the year 2021.
You have to write a complete C program
Program requirements:
1. Declare an integer variable for the month.
2. Prompt the user using printf and read the month number from the user using scanf.
3. Print in the screen if the month given by the user (1 to 12) has 28, 30, or 31 days (You can use if or if...else statements, or the switch statement.)
4. If the user enters a number less than 1 or greater than 12 then print in the screen the message "Please type a number between 1 and 12"
5. Run your program many times to make sure it works for all cases
The following is an example of how your program should look when you execute it:
First Execution:
The number indicates a month from the year 2021.
Enter a number from 1 to 12: 2 This month has 28 days.
Second Execution:
The number indicates a month from the year 2021.
Enter a number from 1 to 12: 4 This month has 30 days.
Third Execution:
The number indicates a month from the year 2021.
Enter a number from 1 to 12: 12 This month has 31 days.
Fourth Execution:
The number indicates a month from the year 2021.
Enter a number from 1 to 12: 87 Please type a number between 1 and 12.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started