<< Click to Display Table of Contents >> Operators |
The if condition valid operators table:
Arithmetic operators |
|||
---|---|---|---|
Name |
Symbol |
Description |
Example |
Add |
+ |
Sum of A and B |
2 + 2 = 4 |
Subtract |
- |
Difference of A and B |
3 - 2 = 1 |
Multiply |
* |
Product of A and B |
3 * 2 = 6 |
Divide |
/ |
Quotient of A and B |
6 / 2 = 3 |
Logical operators |
|||
---|---|---|---|
Name |
Symbol |
Description |
Example |
Equal to |
= |
Is valid if A is equal to B |
Given that x = 4, the expression (x > 4) is false |
Not equal to |
!= |
Is valid if A is not equal to B |
2 != 3 (this is correct because 2 does not equal 3). 2 != 2 (this is not correct because 2 is 2) |
And |
&& |
Is valid if both A and B are correct |
Given that x = 6 and y = 3, the expression (x < 10 && y > 1) is true |
Or |
|| |
Is valid if either A or B is correct |
Given that x = 6 and y = 3, the expression (x = 5 || y = 5) is false |
Comparison operators |
|||
---|---|---|---|
Name |
Symbol |
Description |
Example |
Greater than |
> |
Is valid if A is greater than B |
2 > 1 (this is correct) |
Less than |
< |
Is valid if A is less than B |
2 < 1 (this is not correct) |
Greater than or equal to |
>= |
Is valid if A is greater than or equal to B |
2 >= 1 and 2 >= 2 (this is correct). 2 >= 3 (this is not correct) |
Less than or equal to |
<= |
Is valid if A is less than or equal to B |
2 <= 3 and 2 <= 2 (this is correct). 2 <= 1 (this is not correct) |
Special operators |
|||
---|---|---|---|
Name |
Symbol |
Description |
Example |
True |
true |
A boolean value that represents mathematical and logical truth |
The expression (1 + 1) = 2 is true |
False |
false |
A boolean value that represents mathematical and logical false |
Given W =5, the expression (W =< 4) is false |