About Lesson
Develop a program that takes a month number (1 to 12) as input and prints the corresponding season (spring, summer, autumn, winter) using a switch statement.
#include <stdio.h>
int main() {
int month;// Taking input for the month number
printf(“Enter the month number (1 to 12): “);
scanf(“%d”, &month);// Using a switch statement to determine the season
switch (month) {
case 12:
case 1:
case 2:
printf(“Season: Wintern”);
break;
case 3:
case 4:
case 5:
printf(“Season: Springn”);
break;
case 6:
case 7:
case 8:
printf(“Season: Summern”);
break;
case 9:
case 10:
case 11:
printf(“Season: Autumnn”);
break;
default:
printf(“Invalid month number. Please enter a number between 1 and 12.n”);
}return 0;
}