Operator | Description | Example | Result | Operator | Description | Example | Result | |
---|---|---|---|---|---|---|---|---|
+ |
Addition | x=2 |
4 |
- |
Subtraction | x=2 |
3 |
|
* |
Multiplication | x=4 |
20 |
/ |
Division | 15/5 |
3 |
|
++ |
Increment | x=5 |
x=6 |
% |
Modulus (division remainder) | 5%2 |
1 |
|
-- |
Decrement | x=5 |
x=4 |
Operator | Example | Is the Same as | Operator | Example | Is the Same as | |
---|---|---|---|---|---|---|
= |
x=y |
x=y |
+= |
x+=y |
x=x+y |
|
-= |
x-=y |
x=x-y |
*= |
x*=y |
x=x*y |
|
/= |
x/=y |
x=x/y |
%= |
x%=y |
x=x%y |
Operator | Description | Example | Operator | Description | Example | |
---|---|---|---|---|---|---|
== |
is equal to | 5==8 returns false |
!= |
is not equal | 5!=8 returns true |
|
> |
is greater than | 5>8 returns false |
< |
is less than | 5<8 returns true |
|
>= |
is greater than or equal to | 5>=8 returns false |
<= |
is less than or equal to | 5<=8 returns true |
Operator | Description | Example | Operator | Description | Example | |
---|---|---|---|---|---|---|
&& |
and | x=6 |
|| |
or | x=6 |
|
! |
not | x=6 |
Wife: “I want another baby.” Husband: “That’s a relief, I also really don’t like this one.” |