A statement is usually a test on a variable or the return value of a function. To test those values, we can use some relational operators:
Operator | Meaning | Example |
---|---|---|
== | Equal to | 1 == 1 is TRUE, 1 == 2 is FALSE |
!= | Not equal to | 1 != 2 is TRUE, 1 != 1 is FALSE |
< | Less than | 1 < 2 is TRUE, 2 < 1 is FALSE |
> | Greater than | 2 > 1 is TRUE, 1 > 2 is FALSE |
<= | Less than or equal to | 2 <= 2 is TRUE, 2 <= 3 is TRUE, 3 <= 2 is FALSE |
>= | Greater than or equal to | 2 >= 2 is TRUE, 3 >= 2 is TRUE, 1 >= 2 is FALSE |
If we are taking the following example:
a = 5;
if(a < 6)
{
// Some code
}
Here the value of the variable a is inferior to 6. So the statement is true: the code will be executed.