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# Decision Making (if, if-else, if-else-if ladder, nested if, switch, nested switch)
- C# | Jump Statements (Break, Continue, Goto, Return and Throw)
- C# | How to use strings in switch statement
- Switch Statement in C#
- Switch Expression in C# 8.0
- C# | Count the total number of elements in the List
- C# | Total number of elements present in an array
- Total number of elements in a specified dimension of an Array in C#
- C# | Getting the Largest Window Width of the Console
- C# | Getting an enumerator that iterates through LinkedList<T>
- C# | Getting the type of the current instance
- C# | Getting the keys in a SortedList object
- C# | Getting the Values in a SortedList object
- C# | Getting an enumerator for a range of elements in the ArrayList
- C# | Getting an enumerator for the entire ArrayList
- C# | Getting the key at the specified index of a SortedList object
- C# | Getting the value at the specified index of a SortedList object
- C# | Getting the list of Values of a SortedList object
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.