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

Write a 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: Program to find the largest among 2 numbers, 3 numbers


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.