while loop

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

while loop

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Does a WHILE loop repeat its instructions for as long as a condition remains true?
A False
B True
2. Which keyword marks the start of the repeated instructions in a WHILE loop?
A THEN
B DO
3. Should a WHILE loop be closed with END WHILE?
A Yes
B No
4. Is ENDWHILE written as one word in VCAA pseudocode?
A False
B True
5. Is the WHILE loop's condition checked before or after the first repetition?
A Before
B After

Match the Pairs

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

Left columnRight column
1WHILE count <= 5 DO AThe closing keyword should be written as END WHILE, not ENDWHILE
2END WHILE BStarts a loop that repeats while the condition stays true
3A structure that repeats instructions while a condition remains true CDO
4The keyword that introduces the repeated instructions after the condition DAssignment should use ←, not =
5count ← 0 WHILE count < 3 DO DISPLAY count count ← count + 1 ENDWHILE EWHILE loop
6n ← 1 WHILE n <= 5 DO DISPLAY n n = n + 1 END WHILE FCloses a WHILE loop block

Definitions

WHILE condition DO

Fill in the Blanks

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

1.
WHILE count <= 5 __
2.
WHILE count <= 5 DO DISPLAY count _________
3.
_____ count <= 5 DO
4.
WHILE x > 0 __
5.
A WHILE loop continues to repeat while its condition remains ____

Spot the Error

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

Question 1
A count ← 1
B WHILE count <= 5 DO
C DISPLAY count
D count ← count + 1
E END LOOP
Question 2
A x ← 10
B WHILE x > 0 DO
C PRINT x
D x ← x - 1
E END WHILE
Question 3
A total ← 0
B WHILE total < 100
C total ← total + 10
D END WHILE
Question 4
A n ← 1
B WHILE n <= 5 DO
C DISPLAY n
D n = n + 1
E END WHILE
Question 5
A WHILE score < 100
B score ← score + 10
C DISPLAY score
D END WHILE

Answer Key

while loop
Section A: Quick Questions
Q1
B — True
Q2
B — DO
Q3
A — Yes
Q4
A — False
Q5
A — Before
Section B: Match the Pairs
Q1
WHILE count <= 5 DO → Starts a loop that repeats while the condition stays true
Q2
END WHILE → Closes a WHILE loop block
Q3
A structure that repeats instructions while a condition remains true → WHILE loop
Q4
The keyword that introduces the repeated instructions after the condition → DO
Q5
count ← 0 WHILE count < 3 DO DISPLAY count count ← count + 1 ENDWHILE → The closing keyword should be written as END WHILE, not ENDWHILE
Q6
n ← 1 WHILE n <= 5 DO DISPLAY n n = n + 1 END WHILE → Assignment should use ←, not =
Section C: Definitions
Q1
WHILE condition DO — A loop that repeats its instructions for as long as the given condition remains true, checked before each repetition
Section D: Fill in the Blanks
Q1
WHILE count <= 5 DO
Q2
WHILE count <= 5 DO DISPLAY count END WHILE
Q3
WHILE count <= 5 DO
Q4
WHILE x > 0 DO
Q5
A WHILE loop continues to repeat while its condition remains true
Section E: Spot the Error
Q1
E — A WHILE loop must be closed with END WHILE, not END LOOP.
Q2
C — VCAA pseudocode uses DISPLAY to output a value, not PRINT.
Q3
B — The WHILE condition is missing DO — it should read WHILE total < 100 DO.
Q4
D — Assignment in pseudocode uses ←, not =.
Q5
A — The WHILE condition is missing DO — it should read WHILE score < 100 DO.