Tuesday 14 August 2012

Operators in C

Operators in C

Operators are basically Symbols that perform some operation on Data.

Types of Operators in C

1. Binary Operator

2. Unary Operator

1. Binary Operators Classification :
   a)  Arithmetic Operators ( +  -  *    /  % )

   b)  Relational Operators  ( ==   >   <   >=   <=  != )

   c)  Logical Operators  ( &&  ||   !  )

   d) Assignment Operators / Short Hand Operator ( =     +=    -=    *=     /=     %=  )

   e) Bit-wise Operators  ( &   |   ~   ^  )

2. Unary Operators Classification 
   a) Increment Operators  ( ++ )
         1 ) Pre Increment Operator 
         2) Post Increment Operator 
  b) Decrement Operator ( -- )
         1 ) Pre  Decrement  Operator
         2) Post  Decrement Operator 
 c) Unary Minus Operator  ( - )
 d) Special Operators  
        1) sizeof Operator
        2) Address Operator ( & )
        3) Pointer Operator ( * )
        4) Scope resolution Operator ( :: )
        5) Separator ( , )
   


Short Hand Operator  or Arithmetic Assignment Operators

  a += 100 meaning is  a = a+100
 a *= 100 meaning is  a = a*100
 a /= 100 meaning is   a = a/100
 a -= 100 meaning is  a = a-100

 The Rule of  = in expression
No expressions are allowed in right hand side of  =

 a= 10
 b= 20;
 a+b = c;     //  Error




No comments:

Post a Comment