Wednesday, March 9, 2011

2.8 Increment and Decrement Operators

  • Increment operators ++ add 1 to the operand while decrement operator -- subtract 1 from the operand
  • ++ and -- can be used as prefix or postfix operators, effect might be different depending on use cases
  • The expression ++n increment n before its value is used, while the expression n++ increment after its value is used
  • ++ and -- can only be applied to variables

No comments:

Post a Comment