In: Computer Science
Using c# , Write a program using a switch statement that takes one character value from the user and checks whether the entered value is an arithmetic operator (+, -, * , /)
If not the program display a message that it not of the operators ( (+, -, * , /) .
The required code and corresponding output are as follows. The code is well commented for better understanding.
using System;
using System.Collections.Generic;
using System.Text;
namespace Arithmetic
{
    class Arithmetic
    {
        static void Main(string[] args)
        {
            char op;// declare operator
            Console.Write("Enter the character: ");
            op = Convert.ToChar(Console.ReadLine());//reads operator
            switch (op)//enters in switch structure
            {
            case '+':
                Console.WriteLine(op + " is an arithmetic operator");
                break;
            case '-':
                Console.WriteLine(op + " is an arithmetic operator");
                break;
            case '*':
                Console.WriteLine(op + " is an arithmetic operator");
                break;
            case '/':
                Console.WriteLine(op + " is an arithmetic operator");
                break;
            default:
                Console.WriteLine(op + " is not an arithmetic operator");
                break;
            }
            Console.ReadLine();
        }
 
    }
}
Output:
