previous | start | next

Arithmetic operators

(A useful web site for C++ language reference is: http://www.cppreference.com)

Here are some of the Arithmetic operators in C++ listed from higher precedence to lower. We will learn more about them as the course progresses.

                             
    ++ --                             right
    * / %                             left
    + -                               left
    << >>                             left
    < <= > >=                         left
    == !=                             left
    = += -= *= /= %=                  right
    ,                                 left



    int x = 5;
    x++;  // Side effect is to increment x by 1.

    int a = 5, b = 3;
    int c, d;
    c = a % b;    // % is the 'mod' or remainder operator; 
                  // c's value is set to 2
    d = a/b;      // d's value is 1, the integer quotient

    a += 10;      // This is equivalent to a = a + 10;
   


previous | start | next