Given a number N, the task is to write a C# program to print the number of days in the Month N.
Input: N = 12
Input: N = 2
This task can be done using the following approaches:
1. Using if else statement : Appropriate month number is checked and then number of days in a month is print using else if statement. Number of days are follows :
Month = [1, 3, 5, 7, 8, 10, 12] , Number of days = 31 Month =  , Number of days = 28/29 Month = [4, 6, 9, 11] , Number of days = 30
Below is the implementation of the above approach:
2. Using Switch Condition : Same as Else if , here month number is checked and it is redirected to cases,and then number of days in a month is print. Below is the implementation of the above approach:
- How to Get a Total Number of Days in a Month using built in Functions in C#?
- Getting a Month Name Using Month Number in C#
- C# Program to Find the Number Occurring Odd Number of Times
- Program to Input Weekday Number and Print the Weekday in C#
- C# Program for Count Inversions in an array | Set 1 (Using Merge Sort)
- Program to swap numbers using XOR operator in C#
- C# Program for Minimum number of jumps to reach end
- C# Program to Count number of binary strings without consecutive 1's
- C# Program to Count trailing zeroes in factorial of a number
- C# Program for nth Catalan Number
- Program to find absolute value of a given number
- C# Program to Convert the Octal String to an Integer Number
- Different Ways to Take Input and Print a Float Value in C#
- C# Program to Convert a Binary String to an Integer
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.