Showing a counter in a flowchart

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

Showing a counter in a flowchart

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which shape holds the step 'set count to 0' in a flowchart?
A A decision diamond
B A step box (rectangle)
2. Where should 'set count to 0' go in a flowchart with a counter?
A Inside the loop
B Before the loop starts
3. Which step adds one to the counter?
A count ← count + 1
B count ← 1
4. What shape is used for the question 'count = 5?'
A A decision diamond
B A step box
5. The diamond 'count = 5?' says No. What happens next?
A The arrow goes back and the loop runs again
B The flowchart ends

Match the Pairs

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

Left columnRight column
1count ← 0 AA step box before the loop that sets the counter to 0 so counting starts from zero
2count ← count + 1 BThe counter never goes up because there is no count ← count + 1 step inside the loop, so count = 5? is never Yes.
3The decision diamond asks if the counter has reached the target. Yes leaves the loop and No goes round again. CA step box inside the loop that adds 1 to the counter each time round
4The counter must start at zero in a step box before the loop begins Dcount ← 0
5Loop step box: count ← 0 (inside the loop, before the diamond count = 5?) Ecount = 5? Yes or No
6Loop: Print Hello, then diamond count = 5? and no step box that adds 1 to count Fcount is set back to 0 every time round the loop, so it never reaches 5 and the loop never ends. Set it to 0 once before the loop.

Definitions

count ← count + 1

Fill in the Blanks

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

1.
Step box: count ← _
2.
Loop step box: count ← count _ 1
3.
Loop step box: count ← count + _
4.
Diamond: _____ = 5?
5.
Diamond: count = 5? ___ -> leave the loop No -> go round again

Spot the Error

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

Question 1
A START
B Step box: count ← 5
C Step box: count ← count + 1
D Diamond: count = 5?
E Yes: END. No: back to line 3
Question 2
A START
B count ← 0
C count ← count - 1
D Diamond: count = 5?
E No: go back to line 3
F Yes: END
Question 3
A START
B count ← 0
C count ← count + 1
D Box: count = 5?
E Yes: END
Question 4
A START
B Step box: count ← 0
C Diamond: count ← count + 1
D Diamond: count = 5?
Question 5
A START
B Set count to 1
C Add 1 to count
D Is count = 5?
E No: go back to Add 1

Answer Key

Showing a counter in a flowchart
Section A: Quick Questions
Q1
B — A step box (rectangle)
Q2
B — Before the loop starts
Q3
A — count ← count + 1
Q4
A — A decision diamond
Q5
A — The arrow goes back and the loop runs again
Section B: Match the Pairs
Q1
count ← 0 → A step box before the loop that sets the counter to 0 so counting starts from zero
Q2
count ← count + 1 → A step box inside the loop that adds 1 to the counter each time round
Q3
The decision diamond asks if the counter has reached the target. Yes leaves the loop and No goes round again. → count = 5? Yes or No
Q4
The counter must start at zero in a step box before the loop begins → count ← 0
Q5
Loop step box: count ← 0 (inside the loop, before the diamond count = 5?) → count is set back to 0 every time round the loop, so it never reaches 5 and the loop never ends. Set it to 0 once before the loop.
Q6
Loop: Print Hello, then diamond count = 5? and no step box that adds 1 to count → The counter never goes up because there is no count ← count + 1 step inside the loop, so count = 5? is never Yes.
Section C: Definitions
Q1
count ← count + 1 — A flowchart counter: set count to 0 in a step box, add 1 inside the loop, then ask count = 5? in a diamond. Yes leaves the loop, No goes round again.
Section D: Fill in the Blanks
Q1
Step box: count ← 0
Q2
Loop step box: count ← count + 1
Q3
Loop step box: count ← count + 1
Q4
Diamond: count = 5?
Q5
Diamond: count = 5? Yes -> leave the loop No -> go round again
Section E: Spot the Error
Q1
B — The counter must start at 0 before the loop. If it starts at 5, the test count = 5? is already true. The line should be: Step box: count ← 0.
Q2
C — The counter goes up by 1 each time round the loop. Taking 1 away would take count further from 5. It should be count ← count + 1.
Q3
D — A question with a Yes or No answer goes in a decision diamond, not a step box. It should be Diamond: count = 5?.
Q4
C — Adding 1 is an action, so it belongs in a step box. A diamond is only for Yes/No questions. It should be Step box: count ← count + 1.
Q5
B — The count should start at 0 so that it counts all 5 times round the loop. Starting at 1 would stop after only 4 loops. It should be Set count to 0.