Other Convenient Operators

Learn about some convenient shorthand operators like the prefix and postfix operators to increment and decrement, and the compound assignment operators.

Some operators are convenient shorthands for what would normally be a two-step computation.

The ++ and -- operators

You may come across two unusual-looking operators that may be used as a shorthand for incrementing and decrementing variables. The ++ and -- operators add 1 and subtract 1, respectively, from their operands. For example in the following code snippet, we increment the int variable a and we decrement the int variable b:

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy