# Unary - A note on increment and decrement and operators...

This preview shows pages 1–2. Sign up to view the full content.

A note on increment and decrement, ++ and --, operators whether used as prefix or postfix with variables. They work only with integer variables, not on floating point variables. They are just short hand notations for adding one to or subtracting one from a number. As we have practiced in a programming exercise 3b, you know the different meaning in each pre-and post- case: Postfix: Placing the increment or decrement operator in after the variable means to use the value first, then increment (or decrement) it. x++ ; // is equivalent to x = x + 1; x-- ; // is equivalent to x = x -1 ; Prefix When placing the increment or decrement operator in front of the variable, you intent to increment (or decrement) the value first before using the variable. ++y; // y is add 1 first and the value is being used to represent y. -- y; // y is subtracted 1 first and the value is being used to represent y. If we want to add or subtract more than one to or from a number, we can use a similar

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 01/20/2010 for the course MATH 107 taught by Professor Christinashow during the Spring '08 term at Mesa CC.

### Page1 / 2

Unary - A note on increment and decrement and operators...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online