Operators
Operators are used to perform calculations, comparisons and logical operations.
Arithmetic Operators
Arithmetic operators are used with numeric values.
| Operator | Description |
|---|---|
+ |
Addition |
- |
Subtraction |
* |
Multiplication |
/ |
Division |
% |
Remainder |
Example
Output:
Comparison Operators
Comparison operators compare two values.
| Operator | Description |
|---|---|
== |
Equal |
!= |
Not equal |
> |
Greater than |
< |
Less than |
>= |
Greater or equal |
<= |
Less or equal |
Example
Output:
Logical Operators
Logical operators are used with boolean values.
| Operator | Description |
|---|---|
&& |
And |
|| |
Or |
! |
Not |
Example
Output:
Assignment Operators
Assignment operators modify variables.
| Operator | Description |
|---|---|
= |
Assign |
+= |
Add and assign |
-= |
Subtract and assign |
*= |
Multiply and assign |
/= |
Divide and assign |
Example
Output:
Complete Example
Output: