Drawing a decision inside a loop in a flowchart

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Drawing a decision inside a loop in a flowchart

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. A decision diamond sits inside a loop in a flowchart. How often is it asked?
A Every time the loop goes around (every pass)
B Only once, on the first pass
2. Which describes what happens to the Yes and No branches of a decision inside a loop?
A Only the Yes branch goes back to the loop test; the No branch ends the flowchart
B Both branches rejoin and lead back to the loop test
3. A flowchart loop counts from 1 to 10 and checks if each number is even. Where does the 'is it even?' diamond go?
A Outside the loop, after the loop has finished
B Inside the loop, after the loop test and before the arrow back
4. Where should the counter update (like i ← i + 1) go so that it happens on every pass?
A After the branches rejoin, just before returning to the loop test
B Only on the Yes branch of the decision
5. In a loop with a decision, the No branch does nothing. What should its arrow do?
A Join the Yes branch's path so both continue to the counter update
B Stop with no arrow, because nothing happens on No

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1score >= 50? Ai <= 5? Yes -> n > 3? -> ... -> i <- i + 1 -> back to i <= 5?
2i <- i + 1, then arrow to i <= 10? BThe counter update, then back to the loop test
3Both the Yes and No branches rejoin before the loop test CYes: count <- count + 1 -> join. No: join. Then i <- i + 1 -> i <= 10?
4The decision is asked again on every pass of the loop DThe No branch goes to Stop instead of rejoining. The loop would end the first time the answer is No. It should rejoin and go back to the loop test.
5n > 5? No -> Stop (Yes -> count <- count + 1 -> i <- i + 1 -> i <= 10?) EA decision diamond inside the loop that is asked on every pass
6n > 5? Yes -> count <- count + 1 -> i <- i + 1. No -> i <= 10? FThe counter update is only on the Yes branch. When the answer is No, i never changes, so the loop may never end. Rejoin the branches first, then update i.

Definitions

decision inside a loop

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
A decision in a loop is drawn as a _______
2.
Is score > 10? Yes -> count <- count + 1 __ -> go to counter update
3.
Both branches go back to the _________
4.
Counter update: i <- i _ 1
5.
The diamond is asked _____ pass

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A Set total <- 0, i <- 1
B Loop test: i <= 5? No: End
C Is i > 3? Yes: add i, No: End
D Yes and No: i <- i + 1
E Go back to loop test
Question 2
A Set count <- 0, i <- 1
B Loop test: i <= 10? No: End
C Is i even? Yes: count + 1
D Only Yes: i <- i + 1
E Go back to loop test
Question 3
A Set i <- 1, big <- 0
B Loop test: i <= 8? Yes: End
C Is i > 5? Yes: big <- big + 1
D Yes and No: i <- i + 1
E Go back to loop test
Question 4
A Start: set score <- 0
B Loop test: i <= 6? No: End
C Is i odd? Yes: score+1
D Yes and No: i <- i + 1
E Go back to loop test
Question 5
A Set n <- 0, i <- 1
B Loop test: i <= 7? No: End
C Is i < 4? Yes: n+1
D Yes and No: i <- i + 1
E Go back to loop test

Answer Key

Drawing a decision inside a loop in a flowchart
Section A: Quick Questions
Q1
A — Every time the loop goes around (every pass)
Q2
B — Both branches rejoin and lead back to the loop test
Q3
B — Inside the loop, after the loop test and before the arrow back
Q4
A — After the branches rejoin, just before returning to the loop test
Q5
A — Join the Yes branch's path so both continue to the counter update
Section B: Match the Pairs
Q1
score >= 50? → A decision diamond inside the loop that is asked on every pass
Q2
i <- i + 1, then arrow to i <= 10? → The counter update, then back to the loop test
Q3
Both the Yes and No branches rejoin before the loop test → Yes: count <- count + 1 -> join. No: join. Then i <- i + 1 -> i <= 10?
Q4
The decision is asked again on every pass of the loop → i <= 5? Yes -> n > 3? -> ... -> i <- i + 1 -> back to i <= 5?
Q5
n > 5? No -> Stop (Yes -> count <- count + 1 -> i <- i + 1 -> i <= 10?) → The No branch goes to Stop instead of rejoining. The loop would end the first time the answer is No. It should rejoin and go back to the loop test.
Q6
n > 5? Yes -> count <- count + 1 -> i <- i + 1. No -> i <= 10? → The counter update is only on the Yes branch. When the answer is No, i never changes, so the loop may never end. Rejoin the branches first, then update i.
Section C: Definitions
Q1
decision inside a loop — A diamond on the loop path is asked on every pass. Both its Yes and No branches rejoin, then go back to the loop test, usually after the counter update.
Section D: Fill in the Blanks
Q1
A decision in a loop is drawn as a diamond
Q2
Is score > 10? Yes -> count <- count + 1 No -> go to counter update
Q3
Both branches go back to the loop test
Q4
Counter update: i <- i + 1
Q5
The diamond is asked every pass
Section E: Spot the Error
Q1
C — The No branch of the decision must not end the loop. Both Yes and No rejoin, then go to the counter update and back to the loop test. The line should end with No: skip, or show No rejoining.
Q2
D — The counter update must happen after both branches rejoin. If only the Yes path adds 1 to i, the No path never changes i, so the loop never ends. It should say Yes and No: i <- i + 1.
Q3
B — The loop test branches are swapped. While i <= 8 is true (Yes) the flowchart should carry on to the decision. Only No should lead to End.
Q4
A — The counter i is never given a starting value. The loop test and the update both use i, so it must be set to 1 before the loop. The line should be Start: set score <- 0, i <- 1.
Q5
C — A decision diamond needs both a Yes and a No exit. The No branch is missing, so the flowchart does not say where to go when i < 4 is false. It should add No: skip, which rejoins the path.