Arithmetic Operators : Arithmetic Operators : Operator C# Examples


C# Examples » Operator » Arithmetic Operators »

 

Arithmetic Operators





C# defines the following arithmetic operators:



Operator
Meaning


+
Addition


-
Subtraction (also unary minus)


*
Multiplication


/
Division


%
Modulus


++
Increment


--
Decrement



When / is applied to an integer, any remainder will be truncated.
For example, 10/3 will equal 3 in integer division.




    
using  System;

class  MainClass
{
        static  void  Main(string[]  args)
        {
                int          a,b,c,d,e,f;

                a  =  1;
                b  =  a  +  6;
                Console.WriteLine(b);
                c  =  b  -  3;
                Console.WriteLine(c);
                d  =  c  *  2;
                Console.WriteLine(d);
                e  =  d  /  2;
                Console.WriteLine(e);
                f  =  e  %  2;
                Console.WriteLine(f);
        }
}
    
   
  
   



Output

7
4
8
4
0


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Operator
» Arithmetic Operators