Write C# Program to print day name of week. I have used Visual Studio 2021 for debugging purpose. But you can use any version of visul studio as per your availability.
C# Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
static void Main(string[] args) { int week; Console.WriteLine("Enter week number (1-7): "); week = Convert.ToInt32(Console.ReadLine()); if (week == 1) { Console.WriteLine("Monday"); } else if (week == 2) { Console.WriteLine("Tuesday"); } else if (week == 3) { Console.WriteLine("Wednesday"); } else if (week == 4) { Console.WriteLine("Thursday"); } else if (week == 5) { Console.WriteLine("Friday"); } else if (week == 6) { Console.WriteLine("Saturday"); } else if (week == 7) { Console.WriteLine("Sunday"); } else { Console.WriteLine("Invalid Input! Please enter week in between 1-7."); } Console.ReadLine(); } |
Output: