1.2.3b - structured programming (y12) Flashcards
What is structured programming?
A programming style that uses sequence, selection, iteration, and procedures.
What is sequence?
Code runs in a set order, line by line.
What is selection?
Code chooses between options using conditions (e.g. IF statements).
What is iteration?
Repeating code using loops (e.g. FOR, WHILE).
What is a procedure?
A named block of reusable code that performs a task.
What is a function?
Like a procedure, but it returns a value.
Why use procedures/functions?
To make code modular, reusable, and easier to debug.
What does modular programming mean?
Breaking code into separate, independent modules.
Why is modular code better?
Easier to test, debug, and reuse.
What is a parameter?
A variable passed into a procedure or function.
What is a local variable?
A variable declared inside a procedure – used only there.
What is a global variable?
A variable declared outside procedures – accessible everywhere.
Why avoid global variables?
They can cause bugs and make code harder to maintain.
What is a subroutine?
Another term for a procedure or function.
What does “top-down design” mean?
Breaking a big problem into smaller subproblems.
What are advantages of structured programming?
Makes code readable, easier to maintain, and less error-prone.
What is code indentation?
Spacing used to show structure – essential for clarity.
Why is structured programming good for teams?
Clear logic and modular code make collaboration easier.
What is spaghetti code?
Unstructured, messy code that’s hard to read and debug.
What are built-in functions?
Pre-made functions provided by the language (e.g. len()).
What is recursion?
A function calling itself – used carefully in structured design.
When is structured programming taught?
Often as a foundation in learning to code.
What language features support structured programming?
IF/ELSE, WHILE, FOR, PROCEDURE, FUNCTION.
How does structured programming improve testing?
Individual modules can be tested separately.