C/C++ Operators

Operators

There are many operators in C/C++. They include the normal math operations you're familiar with, as well as a few other ones that might not be so familiar.

Operator Function Desctiption
+ Addition adds the left and right hand sides
- Subtraction subtracts the left and right hand sides
* Multiplication multiplies the left and right hand sides
/ Division divides the left and right hand sides
++ Increment Adds 1 to the variable
-- Decrement Subtracts 1 from the variable
& Logical AND ANDs the left and right hand sides
| Logical OR ORs the left and right hand sides
^ Logical XOR XORs the left and right hand sides
~ Logical NOT inverts all the bits
<< Logical shift left shifts the value left N bits
>> Logical shift right shifts the value right N bits

-- discuss pre/post increment/decrement, give examples of all. split into uniary and rhs/lhs ops perhaps. work on evaluation operators too (!, &&, ||). also need to specify int-only operators (shifts, boolean ops, etc) also look into pointer operator explanation stuff here.
Styles: Default · Green · Sianse