Operators

1.What is an operator?

Ans : An operator is a symbol that operates a variable.

There are six type of operators :

1.     Arithmetic operator.

2.     Assignment operator.

3.     Relational operator.

4.     Logical operator.

5.     Bitwise operator.

6.     Increment and decrement operator. 

a. Arithmetic operator : It Performs Mathematical operations.

 

   Operators name

Symbol

1. Addition

    ‘+’

2.Subraction

     ‘-’

3.Multiplication

     ‘*’

4.Division

     ‘/’

5.Modulus

     ‘%’

b. Assignment operator : It is used for assigning a value to a variable.

                                                 (The most common variable used is '='.)

   Operators

 Examples

 Same as

1. ‘=’

     a=b     

b=a

2. ‘+=’

     a+=b

a=a+b

3. ‘-=’

     a-=b

a=a-b

4. ‘*=”

     a*=b

a=a*b

5. ‘/=’

     a/=b

a=a/b

 

c. Relation operator : It checks relation between two operands.

   Operators

 Meaning

1. ‘==’

Equal to   

2. ‘>’

Greater

3. ‘<’

Lesser 

4. ‘>=”

Greater than equal to

5. ‘<=’

Lesser than equal to

d. Logical operator :

   Operators

 Meaning

1. &&

Logical and : used if Both condition are true. 

2. ||

Logical Or : used if a single condition is true.

3. !

Logical Not: It is true only if operand is zero. 

 

e. Bitwise operator :

 

   Operators

 Meaning

1. &

Equal to   

2. |

Greater

3. ^

Lesser 

4. ~

Greater than equal to

5. !

Lesser than equal to

6.<<

Right shift

7.>>

Left shift

f. Increment and Decrement operator :

 

   Operators

 Meaning

1. ++

Increment operator  : used for increment (addition)   

2. --

Decrement operator : used for decrement   (subtract)