# C Program to Print Number of Days in a Month using If Else Ladder Statement

In this C program, we will learn about how to print number of days in a month using if else ladder statement. We will take a number between 1 to 12 as input from user, where 1 corresponds to January, 2 corresponds to February and so on. We will use if else ladder statement to print number of days in any month in words.

## C program to print number of days in months

```#include <stdio.h>

int main() {
int month;
printf("Enter Month Number\n");
scanf("%d", &month);

/* Input Validation */
if(month < 1 || month > 12){
printf("Invalid Input !!!!\n");
return 0;
}

if(month == 2) {
printf("28 or 29 Days in Month\n");
} else if(month == 4 || month == 6 || month == 9 ||
month == 11) {
printf("30 Days in Month\n");
} else if (month == 1 || month == 3 || month == 5 ||
month == 7 || month == 8 || month == 10 || month == 12) {
printf("31 Days in Month\n");
}

return 0;
}
```
Output
```Enter Month Number
2
28 or 29 Days in Month
```
```Enter Month Number
12
31 Days in Month
```
```Enter Month Number
9
30 Days in Month
```
```Enter Month Number
15
Invalid Input !!!!
```

Related Topics
 C Program to Print Days of Week in Words using Switch Case Statement C Program to Check Whether a Character is Decimal Digit or Not C Program to Check Whether an Alphabet is Vowel or Consonant C Program to Print All Prime Numbers between 1 to N C Program to Find Sum of All Prime Numbers Between 1 to N C Program to Find Sum of All Odd Numbers Between 1 to N using For Loop C Program to Find GCD or HCF of Two Numbers using For Loop C Program to Calculate Power of a Number C program to convert string to integer List of all C programs