Write a C# program to do basic arithmetic calculations

CsharpProgrammingServer Side Programming

Let us do the following arithmetic calculations −

Sr.NoOperator & Description
1+
Adds two operands
2-
Subtracts second operand from the first
3*
Multiplies both operands
4/
Divides numerator by de-numerator

The following is an example to perform arithmetic calculations using the above-given operators −

Example

 Live Demo

using System;

namespace OperatorsApplication {
   class Program {
      static void Main(string[] args) {
         int a = 40;
         int b = 20;
         int c;

         c = a + b;
         Console.WriteLine("Addition: {0}", c);

         c = a - b;
         Console.WriteLine("Subtraction: {0}", c);
     
         c = a * b;
         Console.WriteLine("Multiplication: {0}", c);

         c = a / b;
         Console.WriteLine("Division: {0}", c);

         Console.ReadLine();
      }
   }
}

Output

Addition: 60
Subtraction: 20
Multiplication: 800
Division: 2
raja
Published on 16-Aug-2018 08:52:15
Advertisements