Friday, December 2, 2016
C# program to check Operators | Operators Program in C#
C# program to check entered value is arithmetic operator, logical operator, conditional operator, relational operator or something else
Program Statement:
Write a program using switch statement which takes one character value from user and check whether the entered value is arithmetic operator, logical operator, conditional operator, relational operator or something else.
Solution:
static void Main(string[] args)
{
char ch;
int a;
Console.WriteLine("Enter any Character:");
ch = Convert.ToChar(Console.ReadLine());
a=(int)ch;
switch (ch)
{
case '+':
case '-':
case '*':
case '/':
case '%':
Console.WriteLine("Entered Character is Arithmetic");
break;
case '&':
case '|':
case '!':
Console.WriteLine("Entered Character is Logical Operator");
break;
case '?':
case ':':
Console.WriteLine("Entered Character is Condational Operator");
break;
case '<':
case '>':
case '=':
Console.WriteLine("Entered Character is Relational Operator");
break;
default:
Console.WriteLine("Entered Character is something else not included i n list");
break;
}
Console.ReadLine();
}
Labels:
Csharp,
programming,
programs
Location:
Kitikmeot, Unorganized, NU, Canada