4.1.1.2 Programming concepts Flashcards
What is a keyword?
A word in a programming language that is already defined and can’t be used as an identifier name, e.g print
What is a statement?
A single step within the algorithm
What is iteration?
A section of code executed repeatedly for a given number of times or until a construct is met. It is a basic construct of procedural programming which helps save memory.
What is recursion?
When a function calls itself until it reaches a stopping condition, dividing the program into smaller problems.
Advantages of using iteration instead of recursion
Uses only one set of variables, so it uses less space and is more efficient
Disadvantages of using iteration over recursion
The algorithm is more difficult to follow due to reusing the same variables. You have to ensure the conditions of the loop are right.
What is selection?
A condition that determines whether a section of code will be executed, a basic construct of procedural programming languages
What is nesting?
When a construct is written and completely contained within another construct, e.g a nested loop.
What is an identifier, why are they used?
A symbolic name given to a subroutine / variable which is clear and meaningful.
Required for the program to store values that can change, make the program easier to understand
What are the three combining principles of imperative programming languages?
Sequence, iteration (loops), selection (if)
What is the difference between definite and indefinite iteration?
Definite iteration - e.g for loops, the loop iterates for a specified number of times
Indefinite - e.g white loops, the loop runs until the condition has been met
What features can make high level language programs easier to understand?
Use of indentation to separate out statement blocks;
Use of comments to annotate the program code;
Use of procedures / functions / sub-routines;
Use of constants
use of meaningful identifier names
What are parameters used for in the context of procedures and functions
To pass data/value within programs / to pass data/value in and out of procedures/functions;