Page 36 - 6437
P. 36

-
                                    ine   Value      f     s  40
                                                  -
                                    ine   Value      f     s   5

                          Assignment Operators
                          The following tables lists the assignment operators supported by the C language:


                             Oper         Description                                       Example
                     ator

                             =            Simple  assignment  operator.  Assigns            C  =  A  +  B  will
                                  values  from  right  side  operands  to  left  sideassign the value of A + B to
                                  operand.                                          C


                             +=           Add AND assignment operator. It adds the          C += A is
                                  right  operand  to  the  left  operand  and  assigns  the equivalent to C = C + A
                                  result to the left operand.


                             -=           Subtract  AND  assignment  operator.  It          C -= A is
                                  subtracts  the  right  operand  from  the  left  operand equivalent to C = C - A
                                  and assigns the result to the left operand.




                             *=           Multiply  AND  assignment  operator.  It          C *= A is
                                  multiplies the right operand with the  left operand equivalent to C = C * A
                                  and assigns the result to the left operand.




                             /=           Divide  AND  assignment  operator.  It            C /= A is
                                  divides the left operand with the right operand and equivalent to C = C / A
                                  assigns the result to the left operand.




                             %=           Modulus  AND  assignment  operator.  It           C %= A is
                                  takes modulus using two operands and assigns the equivalent to C = C % A
                                  result to the left operand.



                             <<=          Left shift AND assignment operator.               C <<= 2 is same as
                                                                                    C
                                                                                            = C << 2

                             >>=          Right shift AND assignment operator.              C >>= 2 is same as
                                                                                    C
                                                                                            = C >> 2
                                                                                                      38
   31   32   33   34   35   36   37   38   39   40   41