Page 32 - Modular_V2.0_C++_Flikpbook
P. 32

4                                                                        OPERATORS



                                                                                                         IN C++








                                   Your Aim


                                   to learn about:
                                           Operators                      Operator Precedence
                                              Expressions                    Type Casting



                  C++ is a versatile language that allows the user to perform various mathematical operations.
                  These operations can be performed with the help of operators. In this chapter, you will learn
                  about various types of operators provided by C++.

                     OPERATORS
                  As you know that an operator is a symbol used to perform mathematical and logical calculations.
                  C++ provides six types of operators, which are:

                      Arithmetic Operators                                  Relational Operators
                      Logical Operators                                     Assignment Operators
                      Increment and Decrement Operators                     Ternary Operator
                  Arithmetic Operators


                  Arithmetic operators are general mathematical operators used to perform arithmetic operations.
                  These operators work on two operands. Hence, these operators are called binary operators.
                  C++ provides the following arithmetic operators:

                   Operator        Name                       Description                      Example        Output
                                                                                            (a = 11, b = 4)
                       +       Addition         Adds two operands.                               a + b          15

                        -      Subtraction      Subtracts the right operand from the left        a - b           7
                                                operand.
                        *      Multiplication Multiplies both operands.                          a * b          44

                        /      Division         Divides    the    numerator      by    the       a / b           2
                                                denominator. Returns the quotient.
                       %       Modulus          Divides the numerator by the denominator         a % b           3
                                                and returns the remainder.


                   30
                          Touchpad MODULAR (Ver. 2.0)
   27   28   29   30   31   32   33   34   35   36   37