fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int month;
  5. printf("enter month number (1-12)\n");
  6. scanf("%d",&month);
  7. switch(month){
  8. case 1: printf("The month is January and it has 31 days");
  9. break;
  10. case 2: printf("The month is February and it has 28 days and 29 in leap year");
  11. break;
  12. case 3: printf("The month is March and it has 31 days");
  13. break;
  14. case 4: printf("The month is April and it has 30 days");
  15. break;
  16. case 5: printf("The month is May and it has 31 days");
  17. break;
  18. case 6: printf("The month is June and it has 30 days");
  19. break;
  20. case 7: printf("The month is July and it has 31 days");
  21. break;
  22. case 8: printf("The month is August and it has 31 days");
  23. break;
  24. case 9: printf("The month is September and it has 30 days");
  25. break;
  26. case 10: printf("The month is October and it has 31 days");
  27. break;
  28. case 11: printf("The month is November and it has 30 days");
  29. break;
  30. case 12: printf("The month is December and it has 31 days");
  31. break;
  32. default:printf("month number is not correct");
  33. }
  34. return 0;
  35. }
  36.  
Success #stdin #stdout 0.01s 5288KB
stdin
2
stdout
enter month number (1-12)
The month is February and it has 28 days and 29 in leap year