44 total
By the end of this subtopic, you should be able to:
In programming, a construct is a basic building block used to control what a program does. Constructs help a program make decisions and repeat actions.
In this subtopic, there are two main ideas:
These are very important in pseudocode because they let you write clear instructions for solving problems.
Selection means the program chooses what to do next based on a condition.
A condition is something the program checks. The result is either true or false.
For example:
"Y"?If the condition is true, one action happens. If it is false, a different action may happen.
Selection is useful when a program needs to:
The two selection methods in this topic are:
To write conditions, pseudocode often uses relational operators. These are symbols that compare values.
They produce a result of true or false.
Common relational operators are:
= means equal to<> means not equal to> means greater than< means less than>= means greater than or equal to<= means less than or equal toExample:
Age >= 16
This checks whether Age is 16 or more. If it is, the condition is true.
An IF statement is used when a program needs to make a decision.
The program checks a condition. If the condition is true, it carries out a set of instructions.
Sometimes there is only one possible action when the condition is true. Sometimes there is also another action for when the condition is false. That is where the ELSE clause is used.
Sign in to view full notes