Flowchart for IF ... THEN ... ELSE

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

Flowchart for IF ... THEN ... ELSE

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which shape do you use to draw the condition of an IF statement in a flowchart?
A A decision diamond
B A process rectangle
2. How many paths leave a decision diamond for an IF ... THEN ... ELSE?
A One path that is always followed
B Two: one labelled Yes and one labelled No
3. In a flowchart for IF ... THEN ... ELSE, what happens after the Yes path and the No path have run their statements?
A The two paths join again before the next step
B Each path carries on separately and never meets
4. Which statements are drawn on the No path of a flowchart for IF ... THEN ... ELSE ... ENDIF?
A The statements from the THEN part
B The statements from the ELSE part
5. An IF ... THEN ... ENDIF has no ELSE. How is the No path drawn?
A It is empty and goes straight to the rejoin point
B It is left out, so the diamond has only one exit

Match the Pairs

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

Left columnRight column
1Diamond: Score >= 50 ? AThe Yes and No paths each end separately instead of rejoining, so the next step after ENDIF is never reached
2IF Age >= 13 THEN OUTPUT "Teen" ENDIF BA decision diamond that asks the IF condition and has one Yes path and one No path leaving it
3In IF ... THEN ... ELSE, the Yes path runs the THEN statements and the No path runs the ELSE statements CAn IF without ELSE: the Yes path runs OUTPUT, and the No path is empty and goes straight to the rejoin point
4After the Yes and No paths finish, both flow lines join again so the next statement runs whichever path was taken DThe two flow lines are not labelled, so the reader cannot tell which path is taken when the condition is true or false
5Diamond: Mark >= 50 ? Two arrows leave the diamond with no labels EIF Mark >= 50 THEN OUTPUT "Pass" ELSE OUTPUT "Fail" ENDIF
6Yes path: OUTPUT "Pass" then END No path: OUTPUT "Fail" then END FIF Mark >= 50 THEN Result ← "Pass" ELSE Result ← "Fail" ENDIF OUTPUT Result

Definitions

decision diamond

Fill in the Blanks

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

1.
IF Mark >= 50 ____ OUTPUT "Pass" ENDIF
2.
ELSE OUTPUT "Fail" _____
3.
IF Score __ 50 THEN OUTPUT "Pass" ENDIF
4.
Diamond: Age >= 18 ? ___: OUTPUT "Adult" No: OUTPUT "Child"
5.
IF Age >= 18 THEN OUTPUT "Adult" ____

Spot the Error

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

Question 1
A Start (terminator)
B Input Age (parallelogram)
C Rectangle: Age >= 18?
D Yes: Output "Adult"
E No: Output "Minor"
F Stop (terminator)
Question 2
A Start (diamond)
B Input Temp (parallelogram)
C Diamond: Temp > 30?
D Yes: Output "Hot"
E No: Output "Not hot"
Question 3
A Input Score (parallelogram)
B Diamond: Score >= 40?
C No: Output "Pass"
D No: Output "Fail"
E Stop (terminator)
Question 4
A Input Num (parallelogram)
B Diamond: Num MOD 2 <- 0
C Yes: Output "Even"
D No: Output "Odd"
E Stop (terminator)
Question 5
A Input Pin (rectangle)
B Diamond: Pin = 1234?
C Yes: Output "Open"
D No: Output "Locked"
E Stop (terminator)

Answer Key

Flowchart for IF ... THEN ... ELSE
Section A: Quick Questions
Q1
A — A decision diamond
Q2
B — Two: one labelled Yes and one labelled No
Q3
A — The two paths join again before the next step
Q4
B — The statements from the ELSE part
Q5
A — It is empty and goes straight to the rejoin point
Section B: Match the Pairs
Q1
Diamond: Score >= 50 ? → A decision diamond that asks the IF condition and has one Yes path and one No path leaving it
Q2
IF Age >= 13 THEN OUTPUT "Teen" ENDIF → An IF without ELSE: the Yes path runs OUTPUT, and the No path is empty and goes straight to the rejoin point
Q3
In IF ... THEN ... ELSE, the Yes path runs the THEN statements and the No path runs the ELSE statements → IF Mark >= 50 THEN OUTPUT "Pass" ELSE OUTPUT "Fail" ENDIF
Q4
After the Yes and No paths finish, both flow lines join again so the next statement runs whichever path was taken → IF Mark >= 50 THEN Result ← "Pass" ELSE Result ← "Fail" ENDIF OUTPUT Result
Q5
Diamond: Mark >= 50 ? Two arrows leave the diamond with no labels → The two flow lines are not labelled, so the reader cannot tell which path is taken when the condition is true or false
Q6
Yes path: OUTPUT "Pass" then END No path: OUTPUT "Fail" then END → The Yes and No paths each end separately instead of rejoining, so the next step after ENDIF is never reached
Section C: Definitions
Q1
decision diamond — The flowchart shape for an IF. It asks a question, then the Yes path and the No path each run their own statements and rejoin before the next step.
Section D: Fill in the Blanks
Q1
IF Mark >= 50 THEN OUTPUT "Pass" ENDIF
Q2
ELSE OUTPUT "Fail" ENDIF
Q3
IF Score >= 50 THEN OUTPUT "Pass" ENDIF
Q4
Diamond: Age >= 18 ? Yes: OUTPUT "Adult" No: OUTPUT "Child"
Q5
IF Age >= 18 THEN OUTPUT "Adult" ELSE
Section E: Spot the Error
Q1
C — A decision must be drawn as a diamond, not a rectangle. A rectangle is a process box and cannot have separate Yes and No paths. It should be 'Diamond: Age >= 18?'.
Q2
A — The start of a flowchart is drawn with a terminator (rounded) shape. A diamond is only for decisions. It should be 'Start (terminator)'.
Q3
C — Both paths out of the diamond are labelled No, so there is no Yes path. The first path must be labelled Yes: 'Yes: Output "Pass"'.
Q4
B — A decision diamond asks a question that can be answered Yes or No, so it needs a comparison with = and a question mark. The arrow <- is assignment. It should be 'Diamond: Num MOD 2 = 0?'.
Q5
A — INPUT is drawn with a parallelogram. A rectangle is the process symbol. It should be 'Input Pin (parallelogram)'.