C# Program to display month name according to the month number using Switch Statement

/* C# Program to display month name according to the month number using Switch Statement */
using System;
public class Demo
{
    public static void Main(string[] args)
    {
        int n;
        Console.WriteLine("Month No : ");
        n = Convert.ToInt32(Console.ReadLine());
        switch(n)
        {
            case 1:
            Console.WriteLine("January");
            break;
            case 2:
            Console.WriteLine("February");
            break;
            case 3:
            Console.WriteLine("March");
            break;
            case 4:
            Console.WriteLine("April");
            break;
            case 5:
            Console.WriteLine("May");
            break;
            case 6:
            Console.WriteLine("June");
            break;
            case 7:
            Console.WriteLine("July");
            break;
            case 8:
            Console.WriteLine("August");
            break;
            case 9:
            Console.WriteLine("September");
            break;
            case 10:
            Console.WriteLine("October");
            break;
            case 11:
            Console.WriteLine("November");
            break;
            case 12:
            Console.WriteLine("December");
            break;
            default:
            Console.WriteLine("Invalid Month number\nPlease try again ....\n");
            break;
        }
        Console.ReadLine();
    }
}

Output :
Month No : 10
October



Leave a comment