S11 - 55 iteration Flashcards
how many iterative statements are there?
There are 3 iterative statements
what are the 3 iterative statements?
WHILE, REPEAT and FOR are all iterative statements
what is iteration?
The process of repeating steps
when is a for loop used?
For loops are used when the required number of iterations is known ahead of execution
How does a for loops work?
the for loop would repeat a line of code at a set amount of times.
The programmer can choose how many times iteration can occur.
when is a while loop used?
while loops are used when the number of iterations are not known.
why can a while loop not be used if the required iterations are not known?
Because the variable used to determine when the iteration ends is changing within the iteration itself
why are loops used?
to ensure the code keeps running only if the condition is met.
branching is another word for selection
what is nesting?
more than one loop is involved in a single decision.
what are the properties of a while - endwhile loop?
+ the expression controlling the repetition of the loop must be boolean (true or false)
+ this expression is tested at the start of the loop
what will happen if the boolean value is false in a while - endwhile loop
Since the boolean expression s false at the start the loop will not be executed, control will be passed onto the next statement after endwhile
how many types of loops are there?
there are 4 types of loops
name the types of loops
+ While…endwhile
+ repeat…until
+ for…next
+ nested loops
what are the properties of a repeat…until loop?
+ The boolean expression controlling the loop is written and tested at the end of the loop.
^^^ this means that the loop is always performed at least once