Write C# Program to print day name of week.
I have used Visual Studio 2012 for debugging purpose. But you can use any version of visul studio as per your availability..
using System; public class charpexercise { 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(); } }
Result:
Enter week number (1-7):
6
Saturday
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
I have used Visual Studio 2012 for debugging purpose. But you can use any version of visul studio as per your availability..
Result:
Enter week number (1-7):
6
Saturday
need an explanation for this answer? contact us directly to get an explanation for this answer