Pages

Using C# console Program Add,Subtract,Multiply and Devide Two values and Print Answer.


INPUT

using System.Text;

namespace Muhammad_Ali_lab_3
{
    class Program
    {
        static void Main(string[] args)
        {
            double value1,value2,sum,sub,multipl,divide;
            Console.WriteLine("please enter value1");
            value1 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Please enter value2");
            value2 = Convert.ToInt32(Console.ReadLine());
            sum = value1 + value2;
            sub = value1 - value2;
            multipl=value1*value2;
            divide=value1/value2;
            Console.WriteLine("by adding value1 and value2 we have ans {0}.\nby subtracting value1 and value2 the ans is {1}.\nby multiplying value1 and value2 ans is {2}.\nby dividing value1 and value2 ans is {3}",sum,sub,multipl,divide);
        }
    }

}

OUTPUT:



ALGORITHM:

  • ·         Start,
  • ·         Initializing: double num1,num2,multiply,divide,sum,sub;
  • ·         Output: Please enter num1
  • ·         Set num1: Taking input from the user
  • ·         Output: Please enter num2
  • ·         Set num2: Taking input from the user
  •  
  •  
  • ·         Output: Result
  • ·         Result=ans of multiplication is____,answer of division is ______,ans of subtraction is _____,and ans of addition is _____.


·         End

No comments:

Post a Comment