 # How to find Number of Days in a month

Welcome you all to the Digital Chalkie blog. Today I’m here with an article of  “How to DO It Series”. In this article, we discuss how to read a month as a number from the keyboard and print the number of days in that month. Ok, guys. Let’s move to solve it.

##### Analysing the problem

We know that four months of the year have 30 days and seven moths have 31 days. Alternate February has 28 or 29 days. In this case, we assume that this is not a leap year. We can interpret these data as follows.

[wpdatatable id=3 table_view=regular]

You can see that the seven month – July is a turning point of the pattern of day count and month. So the easiest way is solving this problem is divide the year into two parts using July as the dividing point. Then we can separate months as even and odd.

##### Flow of the solution

The flow of the solution can be written in steps as follows.

1. Input month as a number
2. Define is it greater than or equal or less than to 7
3. If greater than or equal, define even numbers as 30 day months and odd numbers as 31 day months
4. If less than, define even numbers as 31 day months and odd numbers as 30 day months
5. When the number equals to 2, we display number of days as 28.

Here is the correct flow chart used in programming. ##### Final Program

According to the flow chart above, you can write the c language code easily. In here I provide you an example code for your calm. You can simply copy it and run as your program.

###### Number of Days of Month – Program Code
```#include <stdio.h>
#include <stdlib.h>

int main()
{
int month;
printf("Enter the Number of month : ");
scanf("%d",&month);

if (month<=7) //In here we consider 7 months from beginning
{
if (month==2)  //Check is it February
printf("Dates for the month is 28");  //When it is February
else
if (month%2==1) // Check for odd numbers
printf("Dates for the month is 31");
else
printf("Dates for the month is 30");
}
else
{
if (month%2==1)  //Check for odd months after July
printf("Dates for the month is 30");
else
printf("Dates for the month is 31");
}
printf("\n \n This is a program by BMaxx\@Digital Chalkie Educationl Blog \n Thank you for Join with us \n");
return 0;
}

```