Operators

Mathematical

* (multiplication)/ (division)+ (addition)- (subtraction)% (modulus)

Comparative

> (greater than)>= (greater than or equal to)< (less than)<= (less than or equal to)== (checks equality)!= (checks inequality)

Logical

&& (and) - a && b is true if and only if a and b are true|| (or) - a || b is true if and only if at least one of a and b are true

Increment and Decrement

There are the following short forms for incrementing or decrementing numbers.

../_images/fig2.jpg

In addition to a++ and a-- there is ++a and --a which are indistinguishable without a context.

../_images/fig3.jpg

In example 1, a is used first in the a == 5 check and then is incremented, whereas in example 2, a is first incremented and then used in the a == 5 check.