Page 26 - 6437
P. 26

Operators

                          An operator is a symbol that tells the compiler to perform specific mathematical or logical
                   functions. C language is rich in built-in operators and provides the following types of operators:
                                       Arithmetic Operators
                                       Relational Operators
                                       Logical Operators
                                       Bitwise Operators
                                       Assignment Operators
                                       Misc Operators
                          We will, in this chapter, look into the way each operator works.

                          Arithmetic Operators
                          The  following  table  shows  all  the  arithmetic  operators  supported  by  the  C  language.
                   Assume variable A holds 10 and variable B holds 20, then:


                       Operator             Description                                             Example


                               +            Adds two operands.                                      A + B = 30


                               -            Subtracts second operand from the first.                A - B = -10


                               *            Multiplies both operands.                               A * B = 200


                               /            Divides numerator by de-numerator.                      B / A = 2



                               %            Modulus Operator and remainder of after an              B % A = 0
                                     integer division.


                               ++           Increment operator increases the integer value by       A++ = 11
                                     one.


























                                                                                                      28
   21   22   23   24   25   26   27   28   29   30   31