Operators in C Language


Operators:
An operator is a special character that is used for operations. ‘C’ language provides different types of Operators as follows.
-> Assignment operators
-> Arithmetic operators
->Logical operators
->Relational operators 
-->Increment/Decrement Operators
->Bitwise operators
Assignment operators
            An assignment operator is used to store the value of a constant, variable or an expression in to another variable i.e a variable on the left hand side of an operator.
The general assignment operator is equal to (=).
In addition to equal to we have some other assignment operators (updation operators) as follows: +=, --=, *=, /=, %=,   ..etc.
Eg : x = 5;   à value assigned
            x = y;     à variable based assigned
            x = x+3;     à expression based assigned.

Arithmetic Operators
These operators are used to evaluate arithmetic expressions.
‘C’ language provides five arithmetic operators:
 + (addition)
-          (substraction)
   /  (division)
  % (modulus)
  * (multiplication)


Logical Operators
These operators are used to combine two or more conditions.
“C” language provides 3 logical operations.
Logical AND              &&
Logical  OR                ││
Logical NOT                 !
Relational operators:
            These operators are used to compare two values. They are  ==,<=,>=, !=,<,>.
Eg: a=2;   (2 is stored in a )
A==2   (comparing value of ‘2’ and ‘A’)

Increment/ Decrement Operators:
                                    These variable are used to increment or decrement the value of a variable. Two types of increment and decrement operators available.
They are i) prefix operators
             ii) Postfix Operators
In case of prefix operators assignment is done by after completion of operation.
In case of postfix operators assignment is done before the operation.
 ++ (prefix/postfix increment)
--(prefix/postfix decrement)
Eg: a=40      b=a++
      a=41       b=41     value of a, b is 41.
prefix increment (++a)  
 postfix increment (a++) 
  prefix decrement(- -a)
   postfix decrement (a- -)

Bitwise Logical Operators
These operators are used to work with bits of a number.
The following are the bitwise operators:
& -- Bitwise AND
|    -- Bitwise OR
^  -- Bitwise XOR
~  -- Bitwise NOT
BITWISE SHIFT OPERATORS
Bitwise Left Shift ( << )
Bitwise Right Shift ( >> )
(positive values)
Bitwise Right Shift ( >> )
(negative values)

Followers