Flowchart for a REPEAT loop

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

Flowchart for a REPEAT loop

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. In a flowchart for a REPEAT loop, where is the decision diamond placed?
A After the loop body
B Before the loop body
2. A REPEAT loop is drawn in a flowchart. How many times does the body run at least?
A Once
B Zero times
3. In a REPEAT loop flowchart, which decision path goes back to the loop body?
A The YES path
B The NO path
4. In a REPEAT loop flowchart, which decision path leaves the loop?
A The NO path
B The YES path
5. Which statement is true about the exit direction of a REPEAT loop compared with a WHILE loop?
A REPEAT exits on YES, WHILE exits on NO
B REPEAT exits on NO, WHILE exits on YES

Match the Pairs

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

Left columnRight column
1REPEAT INPUT Guess UNTIL Guess = 7 AThe exit directions are the wrong way round. For REPEAT ... UNTIL, YES must leave the loop and NO must go back to the body.
2Guess = 7? NO -> back to INPUT Guess BIn the flowchart, the INPUT Guess process box comes first, then the decision Guess = 7? placed after it, so the body always runs at least once.
3The YES path from the decision leaves the loop, because the UNTIL condition is now TRUE CREPEAT Count ← Count + 1 UNTIL Count = 10
4A REPEAT loop flowchart has the exit direction opposite to a WHILE loop: YES exits, NO loops back DREPEAT INPUT Num UNTIL Num > 0 OUTPUT Num
5Flowchart: decision Age >= 18? drawn BEFORE the body INPUT Age, with YES going into the body EThe NO flow line goes back up to the start of the loop body, so the loop repeats while the UNTIL condition is not yet TRUE.
6Flowchart: after INPUT Pin, decision Pin = 1234? with YES going back to INPUT Pin and NO leaving the loop FThe decision is drawn before the body, which makes a WHILE loop. In a REPEAT loop the body comes first and the decision comes after it.

Definitions

REPEAT ... UNTIL

Fill in the Blanks

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

1.
REPEAT INPUT Number _____ Number > 0
2.
Number > 0? __ -> back to INPUT Number
3.
Number > 0? ___ -> leave the loop
4.
______ INPUT Mark UNTIL Mark >= 0 AND Mark <= 100
5.
REPEAT loop exits when condition is ____

Spot the Error

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

Question 1
A Decision: Is Password empty?
B Decision: Password = Secret?
C NO: back to Input
D YES: Output Welcome
Question 2
A Process: Count <- Count + 1
B Output: Count
C Decision: Count = 5?
D NO: continue to END
E YES: leave the loop
Question 3
A Terminator: END
B Input: Num
C Decision: Num > 0?
D NO: back to Input
E YES: go to END
Question 4
A Terminator: START
B Input: Guess
C Decision: Guess <> Answer?
D NO: back to Input
E YES: Terminator: END
Question 5
A Input: Num
B Process: Sum <- Sum + Num
C Process: Sum > 50?
D NO: back to Input
E YES: Output Sum

Answer Key

Flowchart for a REPEAT loop
Section A: Quick Questions
Q1
A — After the loop body
Q2
A — Once
Q3
B — The NO path
Q4
B — The YES path
Q5
A — REPEAT exits on YES, WHILE exits on NO
Section B: Match the Pairs
Q1
REPEAT INPUT Guess UNTIL Guess = 7 → In the flowchart, the INPUT Guess process box comes first, then the decision Guess = 7? placed after it, so the body always runs at least once.
Q2
Guess = 7? NO -> back to INPUT Guess → The NO flow line goes back up to the start of the loop body, so the loop repeats while the UNTIL condition is not yet TRUE.
Q3
The YES path from the decision leaves the loop, because the UNTIL condition is now TRUE → REPEAT INPUT Num UNTIL Num > 0 OUTPUT Num
Q4
A REPEAT loop flowchart has the exit direction opposite to a WHILE loop: YES exits, NO loops back → REPEAT Count ← Count + 1 UNTIL Count = 10
Q5
Flowchart: decision Age >= 18? drawn BEFORE the body INPUT Age, with YES going into the body → The decision is drawn before the body, which makes a WHILE loop. In a REPEAT loop the body comes first and the decision comes after it.
Q6
Flowchart: after INPUT Pin, decision Pin = 1234? with YES going back to INPUT Pin and NO leaving the loop → The exit directions are the wrong way round. For REPEAT ... UNTIL, YES must leave the loop and NO must go back to the body.
Section C: Definitions
Q1
REPEAT ... UNTIL — In a flowchart, the loop body comes first, then a decision. NO goes back to the body, YES leaves the loop, so the body runs at least once.
Section D: Fill in the Blanks
Q1
REPEAT INPUT Number UNTIL Number > 0
Q2
Number > 0? NO -> back to INPUT Number
Q3
Number > 0? YES -> leave the loop
Q4
REPEAT INPUT Mark UNTIL Mark >= 0 AND Mark <= 100
Q5
REPEAT loop exits when condition is TRUE
Section E: Spot the Error
Q1
A — A REPEAT loop draws the body first, so the flowchart must start with the Input box. Here a decision comes before the body, so the body might never run. Line 1 should be 'Input: Password'.
Q2
D — In a REPEAT flowchart the NO path must return to the loop body. Here NO leaves the loop. It should be 'NO: back to Process'.
Q3
A — A flowchart begins with a START terminator. Line 1 is labelled END, so the program would stop before it begins. It should be 'Terminator: START'.
Q4
C — With REPEAT ... UNTIL, the YES path leaves the loop when the condition is TRUE. The loop should stop when the guess is correct, so the decision must be 'Guess = Answer?', not '<>'.
Q5
C — A question with YES and NO exits must be drawn in a decision diamond, not a process box. Line 3 should be 'Decision: Sum > 50?'.