Operators


To be continued with Operators.......
     
 In this post we are going to take a brief look on the operators like Assignment operator, Conditional operator and bitwise operator..................................

[3].Assignment Operator:The operators which are used to assign a value to the variable are                                        called assignment operators.'=' is most commonly used assignment
                                  operator.
   
                                                     V op=exp;{statment with shorthand operators}
                                        Where V is the variable,op is the operator and exp will be the expression which is used to assign the value to the variable.This is equivalent to
                                                  V=V op(exp);{statement with simple assignment oprator}

------------------------------------------------------------------------------------------------------------
    Statment with simple                                                              statment with
    assignment operator                                                          shorthand operator    
       a=a+1                                                                                            a+=1                                                  
        a=a-1                                                                                              a-=1
       a=a*(n-1)                                                                                       a*=n+1
       a=a/(n+1)                                                                                       a/=n+1
       a=a%b                                                                                            a%=b
------------------------------------------------------------------------------------------------------------
 *Here one question in our mind occur is that if the simple assignment operators then what is the need of the shorthand operators.They are used because they have some advantages like
   [A].What  appear on the left-hand side need not be repeated so it become easier to write.
   [B].Statment become more easier to read.
   [C].Statment is more efficient.


[4].Conditional Operator:
                                            SYNTAX: expA?expB:expC
                     Meaning:According to the example here expA will be execuated first if it will be none Zero(true),then expB will be execuated and its value will become the value of the variable.If expA will be zero then expC will be execuated and its value will become the value of  the variable.To understand it completely let us consider one example;
                                                               p=15;
                                                               q=10;
                                                           x=(p>q)?p:q;

       According to this example the condition is if p>q,and it is true so it is non-zero so the variable will assign the value of p.Therefore x=15.
   
[5].Bitwise Operators:The operators which are used for manipulation of data at bit level are called bitwise operators.They are also known as special operators.There is one condition in bitwise operators is that they are not used with float and double datatype.

                                                      BITWISE OPERATORS
------------------------------------------------------------------------------------------------------------
                   Operators                                                              Meaning
                       &                                                                  bitwise AND
                       |                                                                   bitwise OR
                       ^                                                                   bitwise exclusive OR
                       <<                                                                 shift left
                       >>                                                                 shift right
------------------------------------------------------------------------------------------------------------
Stay Tuned...........................................                                              

Comments