Write C# Program to print day name of week

Write C# Program to print day name of week


Introduction

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..


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

  1. using System;
  2.  
  3. public class charpexercise
  4. {
  5. static void Main(string[] args)
  6. {
  7.  
  8. int week;
  9.  
  10. Console.WriteLine("Enter week number (1-7): ");
  11. week = Convert.ToInt32(Console.ReadLine());
  12.  
  13. if (week == 1)
  14. {
  15. Console.WriteLine("Monday");
  16. }
  17. else if (week == 2)
  18. {
  19. Console.WriteLine("Tuesday");
  20. }
  21. else if (week == 3)
  22. {
  23. Console.WriteLine("Wednesday");
  24. }
  25. else if (week == 4)
  26. {
  27. Console.WriteLine("Thursday");
  28. }
  29. else if (week == 5)
  30. {
  31. Console.WriteLine("Friday");
  32. }
  33. else if (week == 6)
  34. {
  35. Console.WriteLine("Saturday");
  36. }
  37. else if (week == 7)
  38. {
  39. Console.WriteLine("Sunday");
  40. }
  41. else
  42. {
  43. Console.WriteLine("Invalid Input! Please enter week in between 1-7.");
  44. }
  45.  
  46. Console.ReadLine();
  47. }
  48. }

Result

C# language techstudy.org

     





Related Topics




Popular Posts