Program Flow Flashcards
What is the flow of a program?
The order that the steps are carried out in
Controlled using selection statements (if and switch)
IF Statements
To check if a condition is true or false, and lead to different actions depending on choice
NESTED IF Statements
An IF statement within another IF statement
Allow you to check more conditions due to a previous condition being established
SWITCH Statements
To check if a variable has a specific value
When you want different actions to be performed for different values of the same variable
Con of SWITCH Statements
Can only check for one variable
FOR Loops
Repeat code inside them for fixed number if times
e.g. for x = 1 to 100
this means loops 100 times
DO UNTIL Loops
Controlled by a condition at the end of the loop
Repeats until the condition is true
WHILE Loops
Controlled by a condition at the start of the loop
Repeats while the condition is true
What is used at the start and end of a DO UNTIL Loop?
‘do’
‘until’
What is used at the start and end of a WHILE Loop?
‘while’
‘endwhile’
What is used at the start and end of a SWITCH Statement?
‘switch’
‘endswitch’