Show understanding of the characteristics of a number of programming paradigms, with particular focus on the Imperative (Procedural) paradigm.
Imperative (Procedural) Paradigm
The imperative paradigm describes programs as a sequence of commands that change the state of the computer. The procedural style groups these commands into procedures (also called functions or sub‑routines) that can be called from other parts of the program.
Key Characteristics
State and mutable variables: Programs maintain a set of variables whose values can be altered.
Sequential execution: Statements are executed one after another unless altered by control structures.
Control structures: Use of selection (if‑else, switch) and iteration (for, while, do‑while) to direct flow.
Procedures / functions: Encapsulation of a set of statements that can be invoked with arguments and may return a value.
Top‑down design: Problems are broken down into smaller sub‑problems, each solved by a procedure.
Modularity: Procedures can be developed, tested, and reused independently.
Explicit side‑effects: Procedures may modify global or passed‑by‑reference variables.
Typical Structure of a Procedural Program
Define global constants and variables.
Declare prototypes (if required by the language).
Implement procedures/functions.
Write a main routine that orchestrates the overall flow.
Example (Pseudo‑code)
procedure readData()
// reads input and stores in global array
end procedure
procedure sortData()
// sorts the global array using a chosen algorithm
end procedure
procedure displayData()
// outputs the sorted array
end procedure
procedure main()
readData()
sortData()
displayData()
end procedure
Advantages
Simple to understand for beginners – follows natural step‑by‑step reasoning.
Efficient execution; low overhead because the model maps closely to hardware.
Wide language support (C, Pascal, BASIC, Python in procedural style).
Disadvantages
Difficulty managing large code bases – mutable state can lead to bugs.
Limited support for abstraction compared with object‑oriented or functional paradigms.
Reusability can be hindered if procedures are tightly coupled to specific data structures.
Comparison with Other Paradigms
Aspect
Imperative (Procedural)
Object‑Oriented
Functional
Logical
Primary abstraction
Procedures / functions
Objects (state + behaviour)
Pure functions (no side‑effects)
Relations / predicates
State handling
Mutable variables, global state
Encapsulated within objects
Immutable data
Implicit via logical inference
Control flow
Explicit (if, loops, goto)
Method calls, inheritance, polymorphism
Function composition, recursion
Goal‑driven search
Typical languages
C, Pascal, BASIC, Python (procedural style)
Java, C++, Python (OO style)
Haskell, Lisp, Scala (functional style)
Prolog
Ease of reasoning about state
Harder as programs grow
Improved via encapsulation
Straightforward – no side‑effects
Depends on logical rules
Typical Use Cases
System programming where direct hardware manipulation is required.
Embedded systems with limited resources.
Algorithms that are naturally expressed as step‑by‑step procedures (e.g., sorting, searching).
Educational contexts for introducing fundamental programming concepts.
Key Points to Remember for Exams
Identify the use of mutable variables and how they change over time.
Explain how procedures promote modularity and reuse.
Contrast procedural flow (top‑down) with other paradigms’ flow (e.g., data‑driven in functional).
Provide examples of control structures that alter the sequential execution.
Discuss the impact of side‑effects on program correctness and debugging.
Suggested diagram: Flowchart showing the sequence of procedure calls (readData → sortData → displayData) with arrows indicating the flow of control.