top of page
Search

# Arithmetic Operators in C#

Operators are a very useful thing in computing value. While writing a program, you need various types of operators to calculate the value. These operators are categorized as different categories in C sharp tutorial that performs specific task ex. The C# arithmetic operator performs the basic calculation as add, subtraction, multiplication, division, and modulus whereas other operators perform a different kind of task.

The following operators perform arithmetic operations with operands of numeric types:

• Unary ++ (increment), -- (decrement), + (plus), and - (minus) operators

• Binary * (multiplication), / (division), % (remainder), + (addition), and - (subtraction) operators

```using System;

namespace MyApplication
{
class Program
{
static void Main(string[] args)
{
int x = 5;
int y = 3;
Console.WriteLine( x + y);
}
}
}```

Output:

## "-" Subtraction Operator

```using System;

namespace MyApplication
{
class Program
{
static void Main(string[] args)
{
int x = 5;
int y = 3;
Console.WriteLine("Number After Subtracting");
Console.WriteLine(x - y);
}
}
}```

Output:

## "*" Multiplication Operator

```using System;

namespace MyApplication
{
class Program
{
static void Main(string[] args)
{
int x = 5;
int y = 3;
Console.WriteLine("Multiplying Two Numbers");
Console.WriteLine(x * y);
}
}
}```

Output:

## "/" Division Operator

```using System;

namespace MyApplication
{
class Program
{
static void Main(string[] args)
{
int x = 12;
int y = 3;
Console.WriteLine("Dividing the Number");
Console.WriteLine(x / y);
}
}
}```

Output:

## "%" Remainder / Modulus of Number

```using System;

namespace MyApplication
{
class Program
{
static void Main(string[] args)
{
int x = 12;
int y = 5;
Console.WriteLine("Modulus of Number");
Console.WriteLine(x % y);
}
}
}```

Output:

## "X++" Increment Operator

```using System;

namespace MyApplication
{
class Program
{
static void Main(string[] args)
{
int x = 10;
x++;
Console.WriteLine("Increment the Number by 1");
Console.WriteLine(x);
}
}
}```

Output:

## "X--" Decrement Operator

```using System;

namespace MyApplication
{
class Program
{
static void Main(string[] args)
{
int x = 10;
x--;
Console.WriteLine("Decrement the Number by 1");
Console.WriteLine(x);
}
}
}```

Output:

The Tech Platform