Coders Packet

Days in a particular month in C++

By Neeraj Kumar Singhal

C++ program to find Days in a particular month. For example, if we give input as month number 5 and year 2003 and it means days in may, 2003 so it would print May, 2003 has 31 days.

I have written a C++ program that finds the number of days in a given month and year:

The program is pretty straightforward. It follows the general rules and ways to find the days:

1) First, we check given year is a leap year or not.

2) If it is a leap year then we have to find that the given month is February or not.

3) If it is February then days are 29 else it is 28.

4) If the given year is not a leap year then we have declared the array of days and month names.

 

The input to the program should be given like this:

eg:

Input:

Enter month no: 2

Enter the year: 2020

Output: 

February 2020 has 29 Days.

Explanation:

Here '2' means February and it is a leap year. So Days are 29.

 

THANKS

 

Download Complete Code

Comments

No comments yet