| Also known as a
conditional expression, a conditional statement is a
statement performed if true or false. Below are some
examples of conditional statements in programming.
Example 1:
if ($myval < 10) { print "Value is less than
10"; }
If the variable
$myval is less than 10, the software program will print "Value is less than
10".
Example 2:
if ($myval == 10) { print "The value equals 10"; }
In this example if the variable is equal to 10, nothing less,
nothing more than print "The value equals 10".
Example 3:
if ($myval >= 10) {print "Value is greater than or equal to 10"; }
Finally, this example uses two operators. If the variable is
greater than 10 or if it's equal to 10 then print "Value is greater
than or equal to 10".
Also see: Boolean,
Expression,
If statement,
Operator, Programming
definitions, Statement
|