Operators

Arithmetic

Binary operators
+     Addition
- Subtraction
* Multiplication
/ Division (division of 2 integers returns an integer value)
% Modulus (returns the integer remainder) (both operands must be integers)
Unary operators
-     Unary negation (reverses the sign)
++ Increment (can be prefix or postfix)
-- Decrement (can be prefix or postfix)

Assignment

=     Assign

+= Add and assign
-= Subtract and assign
*= Multiply and assign
/ = Divide and assign
%= Modulus and assign

&= Bitwise AND and assign
|= Bitwise OR and assign
^= Bitwise XOR and assign

<<= Left shift (zero fill) and assign
>>= Right shift (zero fill or sign-propogating, depending on the machine) and assign

Comparison

==  : Equal 
!= : Not equal
> : Greater than
>= : Greather than or equal to
< : Less than
<= : Less than or equal to

Conditional

? :   Ternary comparison operator

condition ? val1 : val2 (Evaluates val1 if condition is true; otherwise, evaluates val2)

Boolean

  • Short-circuit logical operations
  • Evaluates the minimal number of expressions necessary
  • Partial evaluation (rather than full evaluation)
&&    and
|| or
! not (logical negation)
  • Logical operators are typically used with Boolean (logical) values; when they are, they return a Boolean value; however, the && and || operators actually return the value of one of the specified operands, so if these operators are used with non-Boolean values, they may return a non-Boolean value.

Bitwise

Binary operators
&     And
| Or
^ Xor

<< Shift left (zero fill)
>> Shift right (zero fill or sign-propogating, depending on the machine)

Zero fill: Vacated bits are filled with zeros.
Sign-propogating: Vacated bits are filled with the leftmost bit (sign bit)
Unary operators
~     Not (inverts the bits) (one's complement)

Pointer

Unary operators
&     Address operator (the address of a value)
* Indirection operator (dereference operator) (dereferencing a pointer to obtain the value pointed to)
Binary operators
->  : Structure pointer operator (dereferencing a pointer to a structure, to obtain
the value of one of the structure members)

Examples

int i = 4;
int *ip;
ip = &i; // Obtaining the address of i using &
int j = *ip; // Dereferencing ip using *

Misc

sizeof   Size-of operator (the amount of memory allocated for the data type, variable, or value)

sizeof <unary-expr>
sizeof (<data-type>)