Programming Techniques Flashcards
(13 cards)
What is sequence in programming?
Sequence means the code runs in order from top to bottom, one instruction after another.
Quick summary of:
1 )Sequence
2) Selection
3) Iteration
Sequence – running code line by line
Selection – using conditions (e.g. IF, CASE)
Iteration – repeating code (e.g. FOR, WHILE)
What is iteration in programming?
Iteration means repeating a block of code using loops like ‘for’ or ‘while’.
What is branching in programming?
Allows the program to make decisions using conditional statements (like ‘if’, ‘then’, ‘else’.)
What is recursion?
A function calls itself to solve a smaller part of a problem.
Give an example of a recursive algorithm.
The factorial function: fact(n) = n * fact(n - 1).
How is recursion different from iteration?
Recursion uses repeated function calls and a base case; iteration uses loops and often uses less memory.
What is modularity in programming?
Breaking a program into smaller-reusable procedures/functions
What is a function in pseudocode?
A block that returns a value, e.g., function calcArea(radius).
What is a procedure in pseudocode?
A block that performs actions but does not return a value.
What is parameter passing by value?
A copy of the value is passed; changes inside the procedure do not affect the original variable.
What is parameter passing by reference?
A reference (address) is passed; changes inside the procedure affect the original variable.
How are OOP techniques used in programming logic?
By using classes, objects, methods, inheritance, encapsulation, and polymorphism to structure and organise code.