Understanding Drawing a loop inside a decision in a flowchart in ACARA Digital Technologies Years 7–8
What it does: After the loop ends, its exit arrow joins the same next step as the No path, so both paths continue together. The first box of the loop hangs off the Yes arrow of the diamond, so the loop only starts when the bin is full. The No arrow goes around the loop, so the loop is skipped completely. If No led into the loop, the loop would not be skipped. In this module the loop is inside the decision. The order is the opposite of a decision inside a loop. A loop can be drawn on either path of a decision. Here it is on the Yes path.
Common mistakes: A question with Yes and No answers must be drawn in a decision diamond, not a step box. It should be 'Start -> Diamond: Any dishes?'. The loop's check must come after the step on the Yes path ('Then -> Diamond: Any left?'). It cannot start straight from Start, because the loop is only reached through the Yes arrow.
Quick Questions
1. A loop is drawn on the Yes arrow of a decision diamond. When does the loop run?
A. Every time the flowchart runs, whatever the answer
B. Only when the answer to the decision is Yes ✓
The loop sits on the Yes path, so it is only entered when Yes is taken.
2. What happens on the No path when the loop is drawn on the Yes path?
A. The loop is skipped and the flow carries on past it ✓
B. The loop runs once and then the flow carries on
The No arrow goes around the loop, so the loop is skipped completely.
3. Where should the exit arrow of the loop go when the loop finishes?
A. It rejoins the main flow after the decision ✓
B. It goes back up to Start
The exit arrow rejoins the main flow so both paths carry on to the same next step.
4. Which flowchart shows a loop that is skipped when the answer is No?
A. The No arrow leads into the first box of the loop
B. The No arrow leads past the loop to the next step ✓
If No led into the loop, the loop would not be skipped.
5. A student draws the loop first and puts the decision diamond inside it. Is this a loop on the Yes path of a decision?
A. No, that is a decision inside a loop ✓
B. Yes, it is the same thing
In this module the loop is inside the decision. The order is the opposite of a decision inside a loop.
Fill in the Blanks
1. IF score > 10 THEN
REPEAT 3 TIMES
OUTPUT "Well done"
Hint: Type the keyword that starts the loop on the Yes path of the decision.
2. IF lights = "off" THEN
REPEAT UNTIL lights = "on"
FLICK switch
Hint: Type the keyword that keeps the loop running until its condition becomes true.
3. END REPEAT
END IF
OUTPUT "Goodbye"
Hint: Type the keyword that closes the decision after the loop has ended. The main flow then rejoins.
4. IF answer = "Yes" THEN
REPEAT UNTIL count = 5
count ← count + 1
Hint: Type the name of the counter variable that the loop checks and changes.
5. IF mark >= 50 THEN
REPEAT 2 TIMES
OUTPUT "Pass"
Hint: Type the operator that means 'greater than or equal to' for the decision diamond.
Spot the Error
Question 1
A
Start -> Step: Any dishes?
B
Yes -> Step: Wash a dish
C
Then -> Diamond: More dishes?
D
Yes -> back to Wash a dish
E
More dishes? No -> Dry up
F
Any dishes? No -> Dry up
Line A — A question with Yes and No answers must be drawn in a decision diamond, not a step box. It should be 'Start -> Diamond: Any dishes?'.
Question 2
A
Start -> Diamond: Homework?
B
Yes -> Step: Do a question
C
Start -> Diamond: Any left?
D
Yes -> back to Do a question
E
Any left? No -> Pack bag
F
Homework? No -> Pack bag
Line C — The loop's check must come after the step on the Yes path ('Then -> Diamond: Any left?'). It cannot start straight from Start, because the loop is only reached through the Yes arrow.
Question 3
A
Start -> Diamond: Monday?
B
No -> Step: Water a plant
C
Then -> Diamond: More plants?
D
Yes -> back to Water a plant
E
More plants? No -> Go inside
F
Monday? No -> Go inside
Line B — The loop belongs on the Yes path, so it only runs when it is Monday. Line 2 should start with 'Yes ->'. Putting it on No would run the loop on the wrong days.
Question 4
A
Start -> Diamond: Bin full?
B
Yes -> Step: Empty the bin
C
Bin full? No -> Empty the bin
D
Empty it -> Diamond: Another?
E
Yes -> back to Empty the bin
F
Another? No -> Wash hands
Line C — The No path must skip the loop and go straight to the step after it. Line 3 should be 'Bin full? No -> Wash hands'. Sending No into the loop means the loop runs even when the bin isn't full.
Question 5
A
Start -> Diamond: Raining?
B
Yes -> Step: Shut a window
C
Then -> Diamond: More windows?
D
Yes -> back to Raining?
E
More windows? No -> Go to bed
F
Raining? No -> Go to bed
Line D — The loop arrow must return to the loop's own step, 'Shut a window'. Going back to the 'Raining?' diamond asks the first decision again instead of repeating the loop.