Write a program to enter a number from 1 to 7 and display the corresponding day of the week.
Sample Solution
C# Sharp Code
Sample Output
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int week; Console.WriteLine("Enter a number "); week = Convert.ToInt32(Console.ReadLine()); switch (week) { case 1: Console.WriteLine("Sunday"); break; case 2: Console.WriteLine("Monday"); break; case 3: Console.WriteLine("Tuesday"); break; case 4: Console.WriteLine("Wednesday"); break; case 5: Console.WriteLine("thursday"); break; case 6: Console.WriteLine("Friday"); break; case 7: Console.WriteLine("saturday"); break; default: Console.WriteLine("Out of range !!"); break; } Console.ReadLine(); } } }
Sample Output
No comments:
Post a Comment