← ACARA Digital Technologies Years 7–8

Error: Yes and No branches swapped

The THEN and ELSE paths are the wrong way round, so the algorithm gives the opposite result for every input. Fix it by swapping the two paths or by flipping the condition.

Understanding Error: Yes and No branches swapped in ACARA Digital Technologies Years 7–8

What it does: The THEN path matches the condition being true and the ELSE path matches it being false, so the branches are in the right order. One input per branch shows the pattern. If both traced outputs are the opposite of the expected ones, the branches (or the condition) are swapped. Swapping the paths makes 50 or more give "Pass" and less than 50 give "Fail". Changing the input does not fix the algorithm. Flipping the condition fixes the logic. Using >= 20 for Hot means the paths are now correct without moving them. If it is raining, you need an umbrella. The paths are swapped, so the output is reversed.

Common mistakes: The condition tests the opposite of what is needed, so the paths are swapped. A mark of 80 would output "Fail". It should be IF mark >= pass THEN. The condition is flipped, so 25 degrees outputs "Hot day" and 35 outputs "Cool day". It should be IF temp > 30 THEN.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

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 420–481) and word search (Modules 420–519).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
An algorithm says: IF age >= 13 THEN OUTPUT "Child ticket" ELSE OUTPUT "Teen ticket". A student aged 15 gets "Child ticket". What is the problem?
The input 15 is not allowedThe THEN and ELSE paths are swapped
Matches
IF temp > 30 THEN OUTPUT "Cold day" ELSE OUTPUT "Hot day"
↓
The THEN and ELSE outputs are swapped. A temperature over 30 is hot, but the algorithm says "Cold day". Fix it by swapping the two outputs.
Applying
Meanings
Term
swapped branches
Meaning
The THEN and ELSE paths are the wrong way round, so the algorithm gives the opposite result for every input. Fix it by swapping the two paths or by flipping the condition.
Practice
INPUT mark
Testing
Gaps
OUTPUT "Fail"
Check Answer
Spots
2SET pass ← 50
3IF mark < pass THEN

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Ermine' badge — Tundra Streak, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. An algorithm says: IF age >= 13 THEN OUTPUT "Child ticket" ELSE OUTPUT "Teen ticket". A student aged 15 gets "Child ticket". What is the problem?
A. The input 15 is not allowed
B. The THEN and ELSE paths are swapped ✓
The condition is true for 15, so THEN runs. But THEN gives the wrong output. The two paths are the wrong way round.
2. A trace table shows that every input gets the opposite answer to what you expect. What is the most likely cause?
A. A variable is missing from the trace table
B. Swapped Yes and No branches ✓
When every input gives the reverse result, think of swapped branches or a condition that tests the opposite.
3. Which is the best way to check for swapped branches?
A. Test one input for each branch ✓
B. Test only one input and assume the rest are fine
One input that makes the condition true and one that makes it false will show whether both paths are the wrong way round.
4. IF score >= 50 THEN OUTPUT "Fail" ELSE OUTPUT "Pass". Which fix works?
A. Swap the two OUTPUT lines ✓
B. Change the score to 50 in the input
Swapping the paths makes 50 or more give "Pass" and less than 50 give "Fail". Changing the input does not fix the algorithm.
5. IF temp < 20 THEN OUTPUT "Hot" ELSE OUTPUT "Cold". Another way to fix this without moving the OUTPUT lines is to:
A. Flip the condition to temp >= 20 ✓
B. Change the word ELSE to ENDIF
Flipping the condition fixes the logic. Using >= 20 for Hot means the paths are now correct without moving them.

Match the Pairs

IF age >= 13 THEN OUTPUT "Child" ELSE OUTPUT "Teen" → The Yes and No paths are swapped: a 15-year-old is told "Child" and an 8-year-old is told "Teen", the opposite of what is right.
IF mark < 50 THEN OUTPUT "Pass" ELSE OUTPUT "Fail" → The condition tests the opposite of what is intended, so low marks pass and high marks fail. Flip the condition to mark >= 50 or swap the two outputs.
A correct decision sends the true (Yes) path to the matching result: if the score is 10 or more, the output is "Win". → IF score >= 10 THEN OUTPUT "Win" ELSE OUTPUT "Lose"
To check for swapped branches, test one input for each branch and compare the traced output with what you expect. → score <- 12, expected "Win", traced "Lose"; score <- 3, expected "Lose", traced "Win"
IF temp > 30 THEN OUTPUT "Cold day" ELSE OUTPUT "Hot day" → The THEN and ELSE outputs are swapped. A temperature over 30 is hot, but the algorithm says "Cold day". Fix it by swapping the two outputs.
IF password = correct THEN OUTPUT "Access denied" ELSE OUTPUT "Welcome" → The Yes and No paths are the wrong way round, so the right password is refused and a wrong one is let in. Swap the two outputs, or change the condition to password != correct.

Key Term

swapped branches
The THEN and ELSE paths are the wrong way round, so the algorithm gives the opposite result for every input. Fix it by swapping the two paths or by flipping the condition.

Fill in the Blanks

1. IF mark >= 50 THEN OUTPUT "Pass" ELSE OUTPUT "Fail" ENDIF
Hint: Type the keyword that starts the false path. If the Pass and Fail paths were swapped, every result would be reversed.
2. IF temp < 15 THEN OUTPUT "Cold" ELSE OUTPUT "Warm" ENDIF
Hint: Type the relational operator that makes the true path match Cold. The wrong operator reverses the output.
3. IF raining = TRUE THEN OUTPUT "Umbrella" ELSE OUTPUT "Sunscreen" ENDIF
Hint: Type the keyword that begins the path followed when the condition is true.
4. IF age >= 18 THEN OUTPUT "Adult" ELSE OUTPUT "Child" ENDIF
Hint: Type the keyword that closes the decision after both the true and false paths.
5. IF light = "red" THEN OUTPUT "Stop" ELSE OUTPUT "Go" ENDIF
Hint: Type the operator that checks whether two values are equal. Test one input per branch to make sure Stop and Go are not swapped.

Spot the Error

Question 1
A INPUT mark
B SET pass ← 50
C IF mark < pass THEN
D OUTPUT "Pass"
E ELSE
F OUTPUT "Fail"
Line C — The condition tests the opposite of what is needed, so the paths are swapped. A mark of 80 would output "Fail". It should be IF mark >= pass THEN.
Question 2
A INPUT temp
B IF temp <= 30 THEN
C OUTPUT "Hot day"
D ELSE
E OUTPUT "Cool day"
Line B — The condition is flipped, so 25 degrees outputs "Hot day" and 35 outputs "Cool day". It should be IF temp > 30 THEN.
Question 3
A INPUT age
B OUTPUT "Checking ticket"
C IF age >= 13 THEN
D OUTPUT "Child ticket"
E ELSE
F OUTPUT "Adult ticket"
Line C — The Yes and No paths are the wrong way round. An age of 8 would get an adult ticket. It should be IF age < 13 THEN.
Question 4
A INPUT password
B IF password ≠ "cloud" THEN
C OUTPUT "Access granted"
D ELSE
E OUTPUT "Access denied"
Line B — Using ≠ reverses the test, so the correct password is denied and a wrong one is granted. It should be IF password = "cloud" THEN.
Question 5
A INPUT lives
B OUTPUT "Lives left:"
C IF lives > 0 THEN
D OUTPUT "Game over"
E ELSE
F OUTPUT "Keep playing"
Line C — The condition is the opposite of what the THEN path expects. With 3 lives the game would say "Game over". It should be IF lives = 0 THEN.

Student with a class code? Join your class →