CIE AS & A Level Computer Science, section 12.2 (Program design)
What a structure chart is
A structure chart is a diagram showing how a program is divided into modules (procedures and functions) and the hierarchy between them. It is used for decomposing a problem into sub-tasks, and for showing the parameters passed between modules.
Features
- The main program is the box at the top.
- Boxes below are the modules it calls, read top to bottom and left to right in order of calling.
- Lines join a module to the modules it calls.
- Arrows with labels show the parameters passed (down to the module) and returned (up).
- A diamond shows a selection and a curved arrow an iteration (a module is called repeatedly).
Worked example: a quiz
AskQuestions calls CheckAnswer repeatedly. ShowScore receives Name and Score.
Deriving pseudocode
Each box becomes a procedure or function, and the main program calls them in order.
PROCEDURE QuizProgram
Name ← GetName()
Score ← AskQuestions()
CALL ShowScore(Name, Score)
ENDPROCEDURE
Benefits
- Shows the overall design at a glance.
- Helps divide work between programmers.
- Makes testing easier, one module at a time.
Common mistake: drawing a structure chart like a flowchart, with decisions and sequences of steps. A structure chart shows modules and their relationships, not the step-by-step flow. Also, label the parameters passed between modules.
Exam tip: start with the main program at the top, list the modules below it in order of use, and label the parameters passed and returned. Show a loop or a selection if the question asks for it.
Check yourself
What is the purpose of a structure chart?
To show how a program is divided into modules and how they are related, including the parameters passed.
Where is the main program drawn?
At the top of the chart.
What does each module in the chart become in the code?
A procedure or a function.