Professional Documents
Culture Documents
Computer Science-2210
Topic: Section
Selection:
Selection statements (sometimes called conditional statements) can be
defined as code (statements) that checks conditions and determines which
code to run.
There are two forms of selection: 1. IF statement, 2. CASE statement.
If statement has three types of condition statement:
1. IF statement:
Structure of IF statement:
IF comparison THEN
Statements that run if the condition is true
ENDIF
2. ELSE:
Structure of IF statement:
IF comparison THEN
Statements that run if the condition is true
ELSE
Statements that run if the condition is false
ENDIF
3. ELSEIF:
Structure of IF statement:
IFcomparison1 THEN
Statements that run if the condition is true
ELSEIF comparison2 THEN
Statements that run if the condition1 is false, and comparison2 is true
ENDIF
CASE Statement:
CASE follows the structure:
CASE OF variable
Value1:
Statement that run if CASE value1 is true
Value2:
Statement that run if CASE value1 is false, and value2 is true
Value1:
Statement that run ifnone of the comparisons are true