Upload
forrester-high-school
View
88
Download
1
Embed Size (px)
Citation preview
Conditional StatementsComputer programs need to make decisions.
We use a conditional statement in programming to test whether or not something is true.
A conditional statement takes the form IF…THEN…
IF something is true THEN do something
ElseThe ELSE statement can be used with the IF statement to provide an alternative outcome from the condition.
The conditional statement can be extended to take the form IF…THEN…ELSE
IF something is true THENdo something
ELSEdo something different
Multiple ConditionsIt is possible to further extend the conditional statement to test for more than one condition.
IF something is true THENdo something
ELSE IF something else is true do something different
ELSE IF something else again is true do something different
etc
Comparison OperatorsSo far we have tested to see if two things are equal, but there are other comparison operators we can use.
Operator Description
= Equal to
< Less than
> Greater than
<= Less than or equal to
>= Greater than or equal to
<> Not equal to