What the diamond on a structure chart means
A structure chart for a car-park program shows the module ChargeVehicle with three modules below it: ChargeCar, ChargeVan and ChargeMotorbike. A small diamond is drawn where the lines from ChargeVehicle to these three modules meet.
What does the diamond show?
A All three modules are called, one after another.
B The three modules are called repeatedly until a condition is met.
C Only one of the three modules is called, depending on a condition.
D Each of the three modules returns a value to ChargeVehicle.
[1]
- 1
Recall the two control symbols on a structure chart. A diamond shows selection: one of the modules below it is called, chosen by a condition (here, the type of vehicle). A curved arrow drawn across the lines shows iteration: the modules below it are called repeatedly.
- 2
Only one charging module runs for each vehicle, so the answer is C (1).
A describes a plain chart with no symbol (modules called in sequence, left to right). B is the iteration arrow. D is shown by upward parameter arrows, not by a diamond.
Answer
C
Examiner tip
Examiner tip: in pseudocode, a diamond becomes an IF … THEN … ELSE … ENDIF or a CASE OF … ENDCASE around the calls; a curved arrow becomes a loop around them.
Common mistake: choosing B because a diamond is the decision symbol in a flowchart, where a decision can create a loop. On a structure chart the diamond only ever means selection.