C# Arithmetic Operators with Examples

  Total Views : 52
  Comments : 0
  Keywords : C# arithmetic operators to perform addition subtraction multiplication division and modulo operations with examples, C# arithmetic operators to perform math operations on operands example

Here we will learn arithmetic operators in c# with examples, different type of arithmetic operators (addition, subtraction, multiplication, division, modulo) in c# with examples and how to use arithmetic operators in c# to perform arithmetic operations with examples.

C# Arithmetic Operators

In c#, Arithmetic Operators are used to perform basic arithmetic calculations like addition, subtraction, division, etc. based on our requirements.


For example, we have an integer variables x = 20, y = 10 and if we apply an arithmetic operator + (x + y) to perform an addition operator, then we will get the result as 30 like as shown below.


int result;

int x = 20, y = 10;

result = (x + y);

Following table lists the different type of operators available in c# arithmetic operators.


OperatorNameDescriptionExample (a = 6, b = 3)
+ Addition It adds two operands. a + b = 9
- Subtraction It subtract two operands. a - b = 3
* Multiplication It multiplies two operands. a * b = 18
/ Division It divides numerator by de-numerator. a / b = 2
% Modulo It returns a remainder as result. a % b = 0

C# Arithmetic Operators Example

Following is the example of using the Arithmetic Operators in c# programming language.


using System;


namespace Tutlane


    class Program


        static void Main(string[] args)


            int result;

            int x = 20, y = 10;

            result = (x + y);

            Console.WriteLine("Addition Operator: " + result);

            result = (x - y);

            Console.WriteLine("Subtraction Operator: " + result);

            result = (x * y);

            Console.WriteLine("Multiplication Operator: "+ result);

            result = (x / y);

            Console.WriteLine("Division Operator: " + result);

            result = (x % y);

            Console.WriteLine("Modulo Operator: " + result);

            Console.WriteLine("Press Any Key to Exit..");





If you observe above code, we used an Arithmetic operators (+, -, *, /, %) to perform different operations on defined operands based on our requirements.

Output of C# Arithmetic Operators Example 

When we execute above c# program, we will get the result like as shown below.


C# Arithmetic Operators Example Result 


This is how we can use arithmetic operators in c# programming language to perform the basic arithmetic calculations on operands based on our requirements.

 Comments (0)

Be the first to give your valuable feedback

Leave a comment

  • Default Tutlane User