C Programming Code Examples C > If Else and Switch Case Code Examples program to find number of days in month program to find number of days in month Write a C program to enter month number between(1-12) and print number of days in month using if else. How to print number of days in a given month using if else in C programming. Total days in a months is given by below table. Month Total days January, March, May, July, August, October, December 31 days February 28/29 days April, June, September, November 30 days Step by step descriptive logic to find number of days in given month. Input month number from user. Store it in some variable say month. For each month check separately and print corresponding number of days in that month using above table. For example, print 31 days if month == 1 since, January contains 31 days. Repeat the above step for all 12 months. #include <stdio.h> int main() { int month; /* Input month number from user */ printf("Enter month number (1-12): "); scanf("%d", &month); if(month == 1) { printf("31 days"); } else if(month == 2) { printf("28 or 29 days"); } else if(month == 3) { printf("31 days"); } else if(month == 4) { printf("30 days"); } else if(month == 5) { printf("31 days"); } else if(month == 6) { printf("30 days"); } else if(month == 7) { printf("31 days"); } else if(month == 8) { printf("31 days"); } else if(month == 9) { printf("30 days"); } else if(month == 10) { printf("31 days"); } else if(month == 11) { printf("30 days"); } else if(month == 12) { printf("31 days"); } else { printf("Invalid input! Please enter month number between (1-12)."); } return 0; }