Control Structure and Loops Flashcards
Control Structures
A control structures include loops, also known as “iteration”, which the code repeat code as many times as needed.
Unconditional loop
The classic unconditional loop is FOR…NEXT where a loop variable is used to keep count of the number of iteration with the NEXT line in this structure used to determine when the loop is complete.
Pre-conditional loops
Conditional loops will continue until an event occurs or a condition is met.
The condition can be at the start, e.g. WHILE, which is known as pre-conditioned loop, so the code inside the loop will not be run at all if the condition is not met when this structure is executed.
Post-conditional
If the condition is at last at the end e.g. REPEAT UNTIL or LOOP UNTIL, it is a post-conditional loop so code inside the loop will run at least once, even the condition has is not met as the test is after the body of the loop. These structure offers the programmer more control over how the loop will work.