Tuesday, August 23, 2011

Operators,Operands & Expression in C

In C language ,to perform any arithmetic or logical computation we used operators.Operators are nothing but the symbols which uses operands or expression to perform these computation.Following are types of Operators available in C:-
1.Arithmetic Operators:
  •     +      to perform Addition
  •     -       to perform Subtraction
  •           to perform Multiplication
  •     /        to perform Division
  •     %      mod for finding remainder in division
  •     ++     for increment
  •     --       for decrement
 
2.Assignment Operators:
  •                  simple assignment
  •    +=             addition assignment 
  •    -=              subtraction assignment
  •    *=              multiplication assignment
  •    /=               division assignment
  •   %=             mod assignment
  •   <<=            left shift assignment
  •   >>=            right shift assignment
  •   &=             bitwise AND assignment
  •   ^=              bitwise exclusive OR assignment
  •   |=               bitwise inclusive  OR assignment 
3.Logical/Relational Operators:
  •   ==         equal to
  •   !=          not equal to
  •   >           greater than
  •   <           less than
  •  >=          greater than or equal to
  •  <=          less than or equal to
  •  &&        logical AND if both operands are non zero condition becomes true
  •   ||            logical OR if either one operand is non zero condition becomes true
  •   !            logical NOT ,use to reverse the logical state of operands if condition is true it will make it false
 
4.Bitwise Operator:
  •    &         binary AND operator
  •     |          binary OR operator
  •     ^         binary XOR operator
  •     ~         Ones Compliment
  •     >>       binary right shift operator
  •     <<       binary left shift operator 
Now something about Expression, it is nothing but combination of operands and operators.i.e
            a=b+c; it is called expression
            where a,b & c are operands, +  and = is operator. 

No comments:

Post a Comment