Write a C# program to do basic arithmetic calculations


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

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 22-Jun-2020

402 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements