Number guessing game algorithm
The guessing game loop: keep asking for a guess until it matches the secret number. Inside, decide too high, too low or correct, and add 1 to the count each time.
Understanding Number guessing game algorithm in ACARA Digital Technologies Years 5–6
What it does: This step makes the counter go up by 1 for each guess, so the game can tell the player how many tries it took. 70 is bigger than 50, so the guess is too high. The player should try a smaller number. To say too low, the algorithm must check guess < secret. The wrong version checks > twice, so 'too low' could never happen. No guesses have been made yet, so count starts at 0. It is not related to the secret number. Every guess is counted, including the winning one. Guesses 3, 9 and 7 make 3 guesses.
Common mistakes: The count must start at 0 because no guesses have been made yet. Starting at 1 makes the total one too many. It should be SET count TO 0. The player types a guess, not the secret number. Typing into secret would change the number being guessed. It should be INPUT guess.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 120–132) and word search (Modules 106–132).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
REPEAT UNTIL guess = secretFill in the Blanks
Spot the Error
Student with a class code? Join your class →