C# Arithmetic Operators

In this chapter you will learn:

  • What is operator in C#?
  • What is Arithmetic Operator?
  • How to use Arithmetic operator in program?
  • What is Escape Character and how to use it?

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

Arithmetic Operators are used for basic mathematical calculation in C# programming. The list of Arithmetic Operators is given below:

Arithmetic Operators:

+Add numbersX=num1+num2
Subtract numbersX=num1-num2
*Multiply numbersX=num1*num2
/Divide numbersX=num1/num2
%Divide two numbers and returns reminderX=22%10 then X will be X=2

  • Output

    Enter first number            15
    Enter second number      12=====================Addition              27
    Subtraction          3
    Multiplication     180
    Division               1.25


    Note: \t,\n these are the special characters in C# that is known as Escape Characters. It is used for special purpose such as inserting line break, backspace etc.


    List of Escape Characters:

    Escape CharactersDescription
    \’Used for single quotation mark
    \”Used for double quotation mark
    \\Used for backslash
    \aAudible alert
    \bUsed for backspace
    \fUsed for form feed
    \nUsed for line break
    \rUsed for Carriage return
    \tUsed for horizontal tab
    \vUsed for vertical tab


    In this chapter, you learned about arithmetic operators in C#. You also learned how to use arithmetic operator in program. Escape characters are provides more functionality in a program so, you learned about different type escape characters in C#. In next chapter you will learn about assignment operators in C sharp.

    3 thoughts on “C# Arithmetic Operators”

    1. At line 31
      div = (float)num1 / num2;

      Your are doing right. but i want to know why we use typecasting(float) in this place ?
      Because we declared div as float variable and giving only int value to num1 & num2 (for ex:- 8,9) but answer is = 0.888888 float type, so we declared div as float variable, variable div stores floating point answer but why we use float near to num1 ((float)num1 / num2;) ???

      Please explain me

    Leave a Reply

    Your email address will not be published. Required fields are marked *