Tech Blog   »   Home   »   Coders Forum   »   Computer Directory   »   Math Calculators   »   RSS:Directory|Forum 

C++ Operators


Assign
Assignment: = ("Right to Left")


Arithmetic
Calculate: + ("Addition")
Calculate: - ("Subtraction")
Calculate: * ("Multiplication")
Calculate: / ("Division")
Calculate: % ("Modulus")


Modulus (%) Operator Quick Answer Table

(Top Row number modulus (%) Right Column end number) == Remainder)

    0 1 2 3 4 5 6 7 8 9 10  	%


    0 0 0 0 0 0 0 0 0 0  0  	1
    0 1 0 1 0 1 0 1 0 1  0  	2
    0 1 2 0 1 2 0 1 2 0  1  	3
    0 1 2 3 0 1 2 3 0 1  2  	4
    0 1 2 3 4 0 1 2 3 4  0  	5
    0 1 2 3 4 5 0 1 2 3  4  	6
    0 1 2 3 4 5 6 0 1 2  3  	7
    0 1 2 3 4 5 6 7 0 1  2  	8
    0 1 2 3 4 5 6 7 8 0  1  	9
     0 1 2 3 4 5 6 7 8 9  0  	 10


   Example: 0 % 5 equals 0.
   Using the table above, you can see how the
   modulus operator works when using it with zeros.




Increase (++)
Increment:    ++    pre(++a)
Increment:    ++    post(a++)

Decrease (--)
Decrement:    --    pre(--a)
Decrement:    --    post(a--)



Compound Assignment
Compounding:   +=    (a += b) same as (a = a + b)
Compounding:   -=    (a -= b) same as (a = a - b)
Compounding:   *=    (a *= b) same as (a = a * b)
Compounding:   /=    (a /= b) same as (a = a / b)
Compounding:   %=    (a %= b) same as (a = a % b)



Equality, Comparison, and Relational Operators
Equal to:       ==   (a == b)
Not equal to:   !=   (a != b)
Greater than:   >    (a > b)
Less than:      <    (a < b)
Greater than or equal to:    >=    (a >= b)
Less than or equal to:       <=    (a <= b)



Logical Operators
Logical (NOT):  !     (!true)               // Evaluates to false.
Returns the opposite boolean value of evaluating its operand.
Logical AND:    &&    ((2 < 3) && (2 < 1))  // Evaluates to true.
This operation evaluates to true if both
of its two operands are true, otherwise false.
Logical OR:     ||    ((1 > 4) || (2 > 1))  // Evaluates to true.
This operation evaluates to true if either one of
its two operands are true, only being false when both operands are false.



Pointer and Reference Operators
Indirection ("variable pointed by a"):  *a
Reference ("address of a"):  &a

Program Examples: C++



More C++ source code

Forum Area maSpinner

The forum contains more programming examples, registration is free!









Validated with no errors:

Valid XHTML 1.0 Transitional     Valid CSS!


Site Map