<<< Assignment Operators     Index     Logical AND, logical OR operators >>>

9. Increment and Decrement Operators

  • Shortcuts to add or subtract 1:

    
        ++i; // add one to i 
        --j; // subtract one from j 
    
    
  • Related topics:

    • (++) and (--) are unary operators

    • side effects

    • always used with modifiable values

  •  

    
    int main()
    {
        int i = 0;
        int k = (i + 1); // No side effects
        int k = ++i; // Side effect: i incremented
        return 0;
    }
    
    
<<< Assignment Operators     Index     Logical AND, logical OR operators >>>