Extended Notes on Structured Programming
🧱 1. Programming Paradigms
Structured programming is one of several paradigms:
-
Procedural Programming: Focuses on procedures or routines (functions)
-
Object-Oriented Programming: Organizes code into objects
-
Functional Programming: Emphasizes immutability and pure functions
Structured programming falls under procedural programming, emphasizing a clear flow of control.
🧮 2. Program Development Cycle
A structured approach follows these steps:
-
Problem Definition
-
Algorithm Design (often using flowcharts or pseudocode)
-
Coding
-
Testing and Debugging
-
Documentation
-
Maintenance
🛠️ 3. Program Design Tools
These help visualize and plan logic:
-
Flowcharts: Graphical representation of logic flow
-
Pseudocode: Plain-language description of steps
-
Structure Charts: Show hierarchy and module relationships
🔁 4. Control Structures
Control structures are the backbone of structured programming:
Type | Description | Example Syntax (C) |
---|---|---|
Sequence | Executes statements in order | a = b + c; |
Selection | Makes decisions | if , else , switch |
Iteration | Repeats actions | for , while , do-while |
📂 5. Data Structures
Structured programming uses basic data structures:
-
Arrays: Fixed-size collections
-
Records/Structs: Group related data
-
Pointers: Reference memory locations
🧩 6. Subprograms (Functions)
Functions promote modularity:
-
Definition:
int add(int a, int b)
-
Call:
add(5, 3)
-
Scope: Local vs. global variables
-
Parameters: Passed by value or reference
📁 7. File Handling
Structured programs often interact with files:
-
Opening/Closing:
fopen()
,fclose()
-
Reading/Writing:
fscanf()
,fprintf()
-
File Types: Text, binary
📝 8. Documentation
Good documentation includes:
-
Inline comments
-
Function headers
-
User manuals
-
Technical specifications
- Teacher: Dan kiplangat