Converting pseudocode to a flowchart

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

Converting pseudocode to a flowchart

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which flowchart symbol do you draw for the pseudocode line: Total ← 0?
A A parallelogram
B A process box (rectangle)
2. Which symbol do you draw for the pseudocode line: INPUT Age?
A A parallelogram
B A decision diamond
3. Which pseudocode statement becomes a decision diamond?
A OUTPUT Mark
B IF Mark >= 50 THEN
4. A flowchart has a diamond containing Count <= 5 and the flow goes back up to it from the loop body. Where was the diamond tested in the pseudocode?
A Before the body, as in WHILE Count <= 5 DO
B After the body, as in REPEAT ... UNTIL Count > 5
5. Where does the decision diamond go when you convert a REPEAT ... UNTIL loop?
A After the loop body
B Before the loop body

Match the Pairs

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

Left columnRight column
1INPUT Age AWHILE Count < 5 DO
2Total ← Total + Mark BDraw a rectangular process box containing this assignment
3An IF condition becomes a decision diamond with a Yes branch and a No branch CDraw a parallelogram containing INPUT Age
4In a WHILE loop the decision diamond comes before the loop body, so the body may never run DOUTPUT must be drawn as a parallelogram, not a process box (rectangle).
5A rectangle drawn for OUTPUT Total EIF Score >= 50 THEN
6REPEAT loop with the diamond drawn before the body FIn a REPEAT ... UNTIL loop the diamond must come after the body, because the body always runs at least once.

Definitions

Pseudocode to flowchart

Fill in the Blanks

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

1.
Total ← 0 // _______ box
2.
OUTPUT Total // _____________
3.
IF Score >= 50 THEN // _______ OUTPUT "Pass" ENDIF
4.
_____ Count < 5 DO // test before body Count ← Count + 1 ENDWHILE
5.
FOR Count ← 1 TO 5 OUTPUT Count NEXT Count // flowchart: Count ← Count + _

Spot the Error

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

Question 1
A Count ← 0 : process
B INPUT Mark : parallelogram
C IF Mark > 50 : process
D OUTPUT Count : parallelogram
Question 2
A Num ← 0 : process
B WHILE Num < 5 DO : diamond
C Num ← Num + 1 : diamond
D ENDWHILE : line to diamond
Question 3
A REPEAT : loop start
B INPUT Pin : parallelogram
C UNTIL Pin = 1234 : process
Question 4
A I ← 1 : process (set counter)
B I <= 3 ? : diamond (test)
C OUTPUT I : parallelogram
D I ← I + 1 : diamond (update)
Question 5
A INPUT Age : parallelogram
B IF Age >= 18 : diamond, 1 exit
C Yes path: OUTPUT Adult
D No path: OUTPUT Minor

Answer Key

Converting pseudocode to a flowchart
Section A: Quick Questions
Q1
B — A process box (rectangle)
Q2
A — A parallelogram
Q3
B — IF Mark >= 50 THEN
Q4
A — Before the body, as in WHILE Count <= 5 DO
Q5
A — After the loop body
Section B: Match the Pairs
Q1
INPUT Age → Draw a parallelogram containing INPUT Age
Q2
Total ← Total + Mark → Draw a rectangular process box containing this assignment
Q3
An IF condition becomes a decision diamond with a Yes branch and a No branch → IF Score >= 50 THEN
Q4
In a WHILE loop the decision diamond comes before the loop body, so the body may never run → WHILE Count < 5 DO
Q5
A rectangle drawn for OUTPUT Total → OUTPUT must be drawn as a parallelogram, not a process box (rectangle).
Q6
REPEAT loop with the diamond drawn before the body → In a REPEAT ... UNTIL loop the diamond must come after the body, because the body always runs at least once.
Section C: Definitions
Q1
Pseudocode to flowchart — Each pseudocode statement becomes one flowchart symbol: assignment is a process box, INPUT/OUTPUT a parallelogram, and IF or loop conditions a decision diamond.
Section D: Fill in the Blanks
Q1
Total ← 0 // process box
Q2
OUTPUT Total // parallelogram
Q3
IF Score >= 50 THEN // diamond OUTPUT "Pass" ENDIF
Q4
WHILE Count < 5 DO // test before body Count ← Count + 1 ENDWHILE
Q5
FOR Count ← 1 TO 5 OUTPUT Count NEXT Count // flowchart: Count ← Count + 1
Section E: Spot the Error
Q1
C — An IF condition is a question, so it becomes a decision diamond, not a process box. It should read IF Mark > 50 : diamond.
Q2
C — An assignment becomes a process box (a rectangle). Only conditions use a diamond. It should read Num ← Num + 1 : process.
Q3
C — The UNTIL condition is a test, so it becomes a decision diamond placed after the body. It should read UNTIL Pin = 1234 : diamond.
Q4
D — A FOR loop's counter update is an assignment, so it is a process box. Only the test is a diamond. It should read I ← I + 1 : process (update).
Q5
B — A decision diamond always has two exits, labelled Yes and No. It should read IF Age >= 18 : diamond, Yes/No.