Worked solution from the Software Development Paper 2 Problem-solving and Programming booklet, Part 2 of 3.
A function returns a value. Mod-B returns a Boolean and Mod-E returns an integer.
Write: Mod-B and Mod-E [1]
Say what happens to Par3 in each module after the call ends:
By reference (Mod-G): any change made to Par3 inside Mod-G is kept, so the changed value is seen in the calling module Mod-C afterwards [1]
By value (Mod-F): a copy is used, so any change made to Par3 inside Mod-F is not seen in Mod-C afterwards [1]
Draw the chart with Mod-A at the top, Mod-B and Mod-C below it, and Mod-D, Mod-E, Mod-F, Mod-G on the bottom row. Draw it like this:
Boxes: Mod-A at the top. Mod-B and Mod-C under it. Mod-D and Mod-E under Mod-B. Mod-F and Mod-G under Mod-C. Join them with lines. [1]
Mod-A to Mod-B: arrows for Par1 and Par2 going down, and a Boolean return value going up [1]
Mod-A to Mod-C: Par1 going down, and Par3 going down and up (two-way, because it is by reference) [1]
Draw a decision diamond under Mod-B only, because it calls either Mod-D or Mod-E [1]
Draw an iteration (curved) arrow across the lines under Mod-C only, because it repeats Mod-F then Mod-G [1]
Lower level: Par2 down to Mod-D; Par3 down to Mod-E with an integer return value up; Par3 down to Mod-F; Par3 two-way to Mod-G [1]
▶ Starts at Q7 (1:00:17)
Starts at Q7 (1:00:17) · by Pseudocode Pro. Tap the picture to open it on YouTube.
Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.