Operators That Compute

 

Arithmetic Operators

 

Unary operators operate on one argument(expression). Binary operators operate on two arguments (expressions).

See my Web Site C++ Tutorial for a complete list of all operators with their precedence, associativity and example of usage.

 

Increment and Decrement Operators:

--counter; //decrement prefix notation

quantity--; //decrement postfix notation

++amount;  //increment prefix notation

offset++; //increment postfix notation

 

Rule:

Prefix operators change the variable before it contributes to the expression.

Postfix operators change the variable after it contributes to the expression.

 

Introducing the std::cin Object:

Cin is the standard input device – the keyboard. The cin object uses the extraction operator,( >> ), which is erroneously depicted in the textbook as “>”  due to some printing problem. Another error you may find in the textbook is the decrement operator, (- -), which often looks like a single dash.