using System;
public class examif
{
public static void Main()
{
int a;
Console.WriteLine("\n");
Console.Write("enter the Grade(1,2,3,4,5) : ");
a = Convert.ToInt32(Console.ReadLine());
switch(a)
{
case 1 :
Console.WriteLine("\nExcellent!");
break;
case 2 :
case 3 :
Console.WriteLine("\nWell done");
break;
case 4 :
Console.WriteLine("\nYou passed");
break;
case 5 :
Console.WriteLine("\nBetter try again");
break;
default:
Console.WriteLine("\nInvalid grade");
break;
}
}
}C#
Branching Statement : switch Statement

Written by
View ProfileSenthilvelan Sambamoorthy
Senthilvelan Sambamoorthy is working as a Professor in Department of Master of Computer Applications, Paavai Engineering College, Namakkal, Tamilnadu, India, He is Masters in Computers Applications. Having 18+ years of experience and his area of interest is Java, JSP, Servlet, J2EE, C#, PHP, Python ASP.NET, SQL Server and etc.
