C program to print the number of days in a month using switch statements

In this post we will use switch statement to print the number of days in a month. So we have given the full code for it and output.

Code for c program to print the number of days in a month using switch statements

#include<stdio.h>
#include<conio.h>
int main()
{
int month;
printf(" Please Enter the Month number 1 to 12: ");
scanf("%d", &month);
switch(month)
{
case 2:
printf("28/29 days");
break;
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
printf("31 days");
break;
case 4:
case 6:
case 9:
case 11:
printf("30 days");
break;
default:
printf("Invalid input! Please enter month number between 1-12");
}
return 0;
}

Output

Please Enter the Month number 1 to 12: 9
30 days

Read: C program to find the maximum of two numbers using switch statement


If You Like This Page Then Make Sure To Follow Us on Facebook, G News and Subscribe Our YouTube Channel. We will provide you updates daily.
Shares
facebook sharing button Share
twitter sharing button Tweet
whatsapp sharing button Share
telegram sharing button Share
pinterest sharing button Pin

Leave a Comment