if - else - elseif
An if
statement will execute the its following code block if the expression
evaluates to true
.
An else
statement following an if
statement can execute its code block if the same expression
is `false``.
if (<condition>) {
...
<code block for 'true'>
...
} else {
...
}
An elseif
statement allows the specification of another expression
, to execute another code block, should the first expression
evaluate to false
.
Example:
if (s == 5) {
printf("s is equal to 5")
} elseif (s < 10) {
printf("s is less than 10 (and is not 5)")
} else {
printf("s is greater or equal to 10")
}