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 is drawn inside a loop. How often is it asked?
A Only on the first pass
B On every pass through the loop
2. In a flowchart, a decision diamond is inside a loop. What should happen to its Yes and No paths?
A Both rejoin into one arrow before the loop test
B Each one goes to its own End shape
3. Which drawing is correct for a loop with a decision inside?
A Loop test, Yes, decision, then a joined arrow back to the loop test
B Loop test, decision, then the Yes arrow back to the loop test and the No arrow stops
4. In a higher or lower game flowchart, the loop test is 'Guess correct?' and the decision is 'Guess too high?'. Where does the 'Guess too high?' diamond go?
A On the loop path, after the guess is entered
B Outside the loop, after the game ends
5. A counter 'guesses = guesses + 1' is added to the higher or lower flowchart. Where is it best drawn?
A Only on the Yes path
B After the decision, once Yes and No have rejoined

Match the Pairs

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

Left columnRight column
1Diamond: Is guess = secret? AThe counter update is on one branch only, so it does not run on every pass.
2Yes path and No path both join, then arrow back to loop test BOnly one path returns to the loop. The paths must both rejoin and then go back to the loop test together.
3In a higher or lower game, the counter goes up after the decision, once both paths have rejoined CDiamond: guess <> secret? -> Yes: Ask for guess, decision, join, back to this diamond
4The loop test asks if the game should keep going, and the arrow from the end of the loop body returns to it DIs guess too high? -> Yes: Show Lower / No: Show Higher -> join -> count <- count + 1
5Yes path of the decision loops back to the loop test, but the No path ends the flowchart EA decision diamond inside the loop body that is asked again on every pass through the loop
6Count <- count + 1 is placed on the Yes path only, so it is skipped when the answer is No FBoth branches rejoin at one point before the flow returns to the loop condition

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 flowchart is a _______
2.
Guess too high? Yes: Say Lower Guess too high? __: Say Higher
3.
Say Lower or Say Higher _____ ← count + 1 Arrow back to the loop test
4.
Both paths ______ before the arrow back
5.
The diamond is asked on _____ loop pass

Spot the Error

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

Question 1
A L{n < 5?} -->|Yes| D{high?}
B D --> H[Say lower]
C D -->|No| W[Say higher]
D H --> C[n = n + 1]
E W --> C
F C --> L
Question 2
A L{go < 5?} -->|Yes| D[high?]
B D -->|Yes| H[Say lower]
C D -->|No| W[Say higher]
D H --> C[go = go + 1]
E W --> C
F C --> L
Question 3
A L{q < 5?} -->|No| D{right?}
B D -->|Yes| S[pts = pts + 1]
C D -->|No| X[Show answer]
D S --> N[q = q + 1]
E X --> N
F N --> L
Question 4
A L{n < 5?} -->|Yes| D{g > 7?}
B D -->|Yes| H[Say lower]
C D -->|No| W[Say higher]
D H --> L
E W --> C
F C --> L
Question 5
A L{n < 5?} -->|Yes| D{even?}
B D -->|Yes| E{sum = sum + n}
C E --> C[n = n + 1]
D D -->|No| C
E C --> L

Answer Key

Drawing a decision inside a loop in a flowchart
Section A: Quick Questions
Q1
B — On every pass through the loop
Q2
A — Both rejoin into one arrow before the loop test
Q3
A — Loop test, Yes, decision, then a joined arrow back to the loop test
Q4
A — On the loop path, after the guess is entered
Q5
B — After the decision, once Yes and No have rejoined
Section B: Match the Pairs
Q1
Diamond: Is guess = secret? → A decision diamond inside the loop body that is asked again on every pass through the loop
Q2
Yes path and No path both join, then arrow back to loop test → Both branches rejoin at one point before the flow returns to the loop condition
Q3
In a higher or lower game, the counter goes up after the decision, once both paths have rejoined → Is guess too high? -> Yes: Show Lower / No: Show Higher -> join -> count <- count + 1
Q4
The loop test asks if the game should keep going, and the arrow from the end of the loop body returns to it → Diamond: guess <> secret? -> Yes: Ask for guess, decision, join, back to this diamond
Q5
Yes path of the decision loops back to the loop test, but the No path ends the flowchart → Only one path returns to the loop. The paths must both rejoin and then go back to the loop test together.
Q6
Count <- count + 1 is placed on the Yes path only, so it is skipped when the answer is No → The counter update is on one branch only, so it does not run on every pass.
Section C: Definitions
Q1
decision inside a loop — A decision diamond on the loop path is asked on every pass. Its Yes and No paths both rejoin before the arrow returns to the loop test.
Section D: Fill in the Blanks
Q1
A decision in a flowchart is a diamond
Q2
Guess too high? Yes: Say Lower Guess too high? No: Say Higher
Q3
Say Lower or Say Higher count ← count + 1 Arrow back to the loop test
Q4
Both paths rejoin before the arrow back
Q5
The diamond is asked on every loop pass
Section E: Spot the Error
Q1
B — Every arrow leaving a decision diamond needs a Yes or No label. Line 2 should be D -->|Yes| H[Say lower].
Q2
A — A decision must be drawn as a diamond, which is { } in Mermaid. D[high?] makes a plain step box. It should be D{high?}.
Q3
A — The Yes exit of the loop test leads into the loop body, where the decision is asked. No leaves the loop. It should be -->|Yes| D{right?}.
Q4
D — The Yes path skips the counter update, so the two paths do not rejoin. Both paths must meet at C[n = n + 1] before returning to the loop test. It should be H --> C[n = n + 1].
Q5
B — Adding to sum is a step, so it needs a rectangle, not a diamond. Only questions get a diamond. It should be E[sum = sum + n].