Nov 12, 2013

Meaning of Comparison, Logical, Assignment and Arithmetic Operators in C++

Unknown | 12:38 PM |

Comparison and Logical Operators

For program flow, the comparison as well as the logical operators is required. The comparison and logical operators can be grouped into three. They are relational operators, equality operators and logical operators.
      OPERATOR
                          MEANING
               <
               >
             <=
             >=
             ==
             !=
             &&
             ||
              !

     Less than
     Greater than
     Less than or equal to
     Greater than or equal to
     Equal to
     Not equal to
     Logical AND
     Logical OR
     Not

Assignment Operators


An assignment operator is used to assign back to a variable, a modified value of the present holding.
   OPERATOR
                                                       MEANING
            =

           +=

            -=

           *=

           /=

           %=

          >>=
          <<=
          &=
          \=
           %=
Assign right hand side (RHS) value to the left hand side (LHS)

Value of LHS variable will be added to the value of RHS and assign it back to the variable in LHS
Value of RHS variable will be subtracted from the value of LHS and assign it back to the variable in LHS
Value of LHS variable will be multiplied by the value of RHS and assign it back to the variable in LHS
 Value of LHS variable will be divided by the value of RHS and assign it back to the variable in LHS
The remainder will be stored back to the  LHS after integer division is carried out between the LHS variable and the RHS variable
Right shift and assign to the LHS
Left shift and assign to the LHS
Bitwise AND operation and assign to the LHS
Bitwise OR  operation and assign to the LHS
Bitwise complement and assign to the LHS


Arithmetic Operators

Arithmetic operations are the basic and common operations performed using any computer programming. Normally, these operators are considered as basic operators and known as binary operators as they require two variables to be evaluated. For example, if we want to multiply any two numbers, one has to enter or feed the multiplicand and the multiplier. That is why it is considered as a binary operator. In C++, the arithmetic operators used are as follows:
           OPERATOR
             MEANING
               +
                -
               *
               /
               %
              addition
              subtraction
              multiplication
              division
              modulo(remainder of an integer division)



2 comments:

Twitter Delicious Facebook Digg Stumbleupon Favorites More

Search