Skip to main content

Write a program to enter a number from 1 to 7 and display the corresponding day of the week. Hint: 1 = Monday ..

using System;
class sevenday
{
public static void Main()
{
int num1;
Console.WriteLine("Enter Number From 1 - 7 to find the correponding day");
num1=Convert.ToInt32(Console.ReadLine());
switch(num1)
{
case 1:
Console.WriteLine(" 1 is Monday");
break;
case 2:
Console.WriteLine("2 is tuesday");
break;
case 3:
Console.WriteLine("3 is wednesday");
break;
case 4:
Console.WriteLine("4 is Thrusday");
break;
case 5:
Console.WriteLine("5 is friday");
break;
case 6:
Console.WriteLine("6 is saturday");
break;
case 7:
Console.WriteLine("7 is sunday");
break;
default:
Console.WriteLine(" Your Number is Invalid Please Enter Correct Number");
break;
}
}
}


Comments

  1. Omaiye good one :) I will be the King of Programmer

    ReplyDelete

Post a Comment

Popular posts from this blog

C# Enumeration

Enumeration provides efficient way to assign multiple constant integral values to a single variable. Enumeration improves code clarity and makes program easier to maintain. Enumeration in C# also provides more security by better error-checking technology and compiler warnings. An enumeration can be defined using enum keyword. In enumeration, you can define special set of value that can be assigned with enumeration. For Example, you are creating an attendance log application in which a variable can contains value only Monday to Friday. The other value will not be applicable with variables. In order to fulfill this requirement you need to use enumeration that will hold only assigned values and will returns numeric position of values starting with zero. Programming Example of Enumeration (C#) using System; namespace Enumeration {    // creating enumeration for storing day.    public enum attandance    {       ...

C# Array

Array is a collection of variable of same data type. If you have declare 1000 integer variable, then you can declare an integer type array of 1000 size. The value of array can be accessed using index position of array. The first index position of array is zero. In C#, there two types of array: Single Dimensional Array and Multi Dimensional Array. You can use both type of array easily and can access its element using loop constructs or index position.