Structure of Procedural Programs Flashcards
State and describe the three main consturucts of procedural programming.
Itteration - Repeating the execution of code multiple times.
Selection- Only executing code based if certain conditions are true.
Sequence- executing instruction in order.
By - Liam Bradshaw
Define recursion.
Recursion is when a fuction will call itself with updated parameters until the fuctions job is done.
By - Liam Bradshaw
State the most common error that newer programers encounter when using recursion.
The mistake that many encounter is to not update the paramters (correctly) causing an infinte loop to occur where it will call itself over and over.
By - Liam Bradshaw
Describe what a while loop and a repeat until loop is?
While loop - A while loop is a form of iteration in which the code iterates while a certain condition is being met e.g. while x<5.
Repeat Until loop - A repeat until loop is a form of iteration in which the computer iterates the code until a condition is met e.g. Repeat until x=5.
State 1 difference between a While loop and a Repeat Until loop.
When using a While loop the condition is evaluated first, and if the condition is true, the code within the block is executed, whereas when using a repeat until loop the code is executed first and then the condition is evaluated, if the condition is true the code is executed again.