Pages

Using C# Console Program Write a Programm that takes Input two Numbers and perform specific function(+ /- / % / * ) using if/else Statment


INPUT

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Calculator
{
    class Program
    {
        static void Main(string[] args)
        {
            char op;
            double no1, no2, res;
            Console.WriteLine(" please enter num1");
            no1 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine(" Please enter num2");
            no2 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine(" Please Select the opperation\n+. Sum\n-. Subtrection\n*. Multiplication\n/. Division");
            op = Convert.ToChar(Console.ReadLine());
            if (op == '+')
            {
                res = no1 + no2;
                Console.WriteLine(" the sum of the given two numbers is {0}", res);
            }
            else
                if (op == '-')
                {
                    res = no1 - no2;
                    Console.WriteLine(" the subtrection of the given two numbers is {0}", res);
                }
                else
                    if (op == '*')
                    {
                        res = no1 * no2;
                        Console.WriteLine(" the Multiplication of the given two numbers is {0}", res);
                    }
                    else
                        if (op == '/')
                        {
                            res = no1 / no2;
                            Console.WriteLine(" the division of the given two numbers is {0}", res);
                        }

          }
     }
}

OUTPUT:




No comments:

Post a Comment