Open syedwaqas2292 opened 2 years ago
{ class program {
static void Main(String[] args) { char op; Double num1, num2; Console.WriteLine("Enter the Operator(+,-,*,/)"); op = Console.ReadLine()[0]; Console.WriteLine("Enter the two numbers one by one"); num1 = Convert.ToDouble(Console.ReadLine()); num2 = Convert.ToDouble(Console.ReadLine()); switch (op) { case '+': Console.WriteLine("{0}+{1}={2}", num1, num2, (num1 + num2)); break; case '-': Console.WriteLine("{0}-{1}={2}", num1, num2, (num1 - num2)); break; case '*': Console.WriteLine("{0}*{1}={2}", num1, num2, (num1 * num2)); break; case '/': if (num2 == 0.0) Console.WriteLine("Divide By Zero situation"); else Console.WriteLine("{0}/{1}={2}", num1, num2, (num1 / num2)); break; default: Console.WriteLine("{0} is an invalid operator", op); break; } Console.WriteLine("Press Any Key to Exit the Program"); Console.ReadKey(); } }
}
Alright
{ class program {
}