Conditional Structures
Introduction to Conditional Structures
In pseudocode, there are two types of conditional structures that are utilised, being IF statements and CASE statements.
IF Statements
IF statements utilise a specific set of keywords that need to be included, being IF, THEN, ENDIF.
E.g:
IF statements can also include an ELSE clause to be able to branch into other code depending on if the IF statement has passed or not.
E.g:
Nested IF statements can also be used, however, care must be taken with inserting ENDIFs into the correct locations. An example of this would be:
CASE Statements
CASE statements are where multiple branches of code can be executed, depending on the value of the variable given to the statement. They follow the keywords CASE OF, ENDCASE.
E.g:
An OTHERWISE clause can be added, which acts similarly to an ELSE clause. It must always be the last case.
E.g:
Last updated