Page 90 - CA_Blue( J )_Class9
P. 90

5.3 TYPES OF OPERATORS
                  Java language provides different types of operators to do a variety of operations.
                  The different types of operators are:


                                                          TYPES OF OPERATORS





                    Arithmetic     Relational      Logical       Bitwise     Assignment     Conditional      Misc.
                     operators     operators      operators     operators     operators     operators      operators



                  5.3.1 Arithmetic Operators
                  Arithmetic operators are used to perform basic and advanced mathematical operations on operands which are of
                  primitive data types. Here, mainly two forms of operators are used. They are unary and binary operators.

                                                           Arithmetic Operators

                                Sl.                                                  Example
                                No.     Operator Name         Operator Symbol       m=10, n=5     Output
                                 1.  Addition                        +                m + n         15

                                 2.  Subtraction                      -               m - n          5

                                 3.  Multiplication                  *                m * n         50

                                 4.  Division                        /                m / n          2
                                 5.  Remainder or Modulus            %                m % n          0

                                 6.  Unary plus                      +                +m            10

                                 7.  Unary minus                      -               -m           -10

                                 8.  Increment                       ++               ++m           11

                                 9.  Decrement                       --               m--           10

                  Let us study about these arithmetic operators in details.


                  Addition (+) Operator
                  The addition (+) operator is used for adding two values or operands either of integer literals or real literals. The
                  result may be positive or negative depending on the values. For examples,
                         If m = 10 and n = 5,   then   m + n = 10 + 5 = 15

                         If m = -40, n = 2,    then   m + n = -40 + 2 = -38

                         If i = -10.5, j = 10,   then   i + j = -10.5 + 10 =  -0.5









                    88    Touchpad Computer Applications-IX
   85   86   87   88   89   90   91   92   93   94   95