Converting a flowchart to pseudocode

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

Converting a flowchart to pseudocode

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. A flowchart has a diamond that asks 'Mark >= 50?' with a Yes branch and a No branch. Which pseudocode does it become?
A FOR Mark <- 50 TO ... NEXT Mark
B IF Mark >= 50 THEN ... ELSE ... ENDIF
2. In a flowchart, the flow line leaves a diamond, goes through some processes, and then returns to the same diamond. Which loop is this?
A WHILE ... DO ... ENDWHILE
B REPEAT ... UNTIL
3. In a flowchart, the processes come first. A diamond after them sends the 'No' flow line back up to the first process. Which loop is this?
A WHILE ... DO ... ENDWHILE
B REPEAT ... UNTIL
4. You have turned a flowchart's decision diamond into an IF statement. What must you add at the end?
A ENDIF
B ENDWHILE
5. A flowchart parallelogram contains the text 'Output Total'. Which line of pseudocode matches it?
A OUTPUT Total
B INPUT Total

Match the Pairs

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

Left columnRight column
1Diamond: Mark >= 50? Yes → OUTPUT "Pass", No → OUTPUT "Fail" AConvert the diamond into IF ... THEN ... ELSE ... ENDIF, with each branch becoming its own statement
2Diamond: Count < 10? Yes → process → arrow back above the diamond BREPEAT INPUT Number UNTIL Number >= 1
3A flowchart loop tests at the bottom, and a back arrow returns when the answer is No (invalid), so it becomes a REPEAT loop CThe ENDIF is missing, so the decision from the flowchart is not closed
4Every statement in a flowchart must be written with the keywords in capitals once it is turned into pseudocode DA FOR loop is closed with NEXT, not ENDFOR, so the wrong closing keyword was written
5IF Age >= 18 THEN OUTPUT "Adult" ELSE OUTPUT "Child" EIF Score > 70 THEN OUTPUT "Merit" ENDIF
6FOR Count ← 1 TO 5 OUTPUT Count ENDFOR FA back arrow to before the test means a loop; testing first with Yes continuing the loop gives WHILE ... DO ... ENDWHILE

Definitions

Flowchart to pseudocode

Fill in the Blanks

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

1.
IF Mark >= 50 THEN OUTPUT "Pass" _____
2.
_____ Lives > 0 DO Lives ← Lives - 1 ENDWHILE
3.
REPEAT INPUT Guess _____ Guess = 7
4.
FOR Count ← 1 TO 5 OUTPUT Count ____ Count
5.
INPUT Num Total ← Total + Num ______ Total

Spot the Error

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

Question 1
A INPUT Mark
B IF Mark >= 50 THEN
C OUTPUT "Pass"
D ENDWHILE
E OUTPUT "Done"
Question 2
A Count ← 0
B WHILE Count < 5 DO
C output Count
D Count ← Count + 1
E ENDWHILE
Question 3
A if Score > 90 THEN
B OUTPUT "Top"
C ENDIF
Question 4
A Total ← 0
B FOR Num ← 1 UNTIL 10
C Total ← Total + Num
D NEXT Num
Question 5
A IF Age >= 18
B OUTPUT "Adult"
C ELSE
D OUTPUT "Child"
E ENDIF

Answer Key

Converting a flowchart to pseudocode
Section A: Quick Questions
Q1
B — IF Mark >= 50 THEN ... ELSE ... ENDIF
Q2
A — WHILE ... DO ... ENDWHILE
Q3
B — REPEAT ... UNTIL
Q4
A — ENDIF
Q5
A — OUTPUT Total
Section B: Match the Pairs
Q1
Diamond: Mark >= 50? Yes → OUTPUT "Pass", No → OUTPUT "Fail" → Convert the diamond into IF ... THEN ... ELSE ... ENDIF, with each branch becoming its own statement
Q2
Diamond: Count < 10? Yes → process → arrow back above the diamond → A back arrow to before the test means a loop; testing first with Yes continuing the loop gives WHILE ... DO ... ENDWHILE
Q3
A flowchart loop tests at the bottom, and a back arrow returns when the answer is No (invalid), so it becomes a REPEAT loop → REPEAT INPUT Number UNTIL Number >= 1
Q4
Every statement in a flowchart must be written with the keywords in capitals once it is turned into pseudocode → IF Score > 70 THEN OUTPUT "Merit" ENDIF
Q5
IF Age >= 18 THEN OUTPUT "Adult" ELSE OUTPUT "Child" → The ENDIF is missing, so the decision from the flowchart is not closed
Q6
FOR Count ← 1 TO 5 OUTPUT Count ENDFOR → A FOR loop is closed with NEXT, not ENDFOR, so the wrong closing keyword was written
Section C: Definitions
Q1
Flowchart to pseudocode — Follow the flow lines and turn each symbol into a statement. A diamond becomes IF, a back arrow shows a loop, and you add ENDIF, NEXT, ENDWHILE or UNTIL. Write keywords in capitals.
Section D: Fill in the Blanks
Q1
IF Mark >= 50 THEN OUTPUT "Pass" ENDIF
Q2
WHILE Lives > 0 DO Lives ← Lives - 1 ENDWHILE
Q3
REPEAT INPUT Guess UNTIL Guess = 7
Q4
FOR Count ← 1 TO 5 OUTPUT Count NEXT Count
Q5
INPUT Num Total ← Total + Num OUTPUT Total
Section E: Spot the Error
Q1
D — The diamond became an IF, so the decision must be closed with ENDIF. ENDWHILE belongs to a WHILE loop. The line should be ENDIF.
Q2
C — Keywords must be written in capitals when converting a flowchart to pseudocode. The line should be OUTPUT Count.
Q3
A — The decision diamond becomes an IF statement, and keywords must be in capitals. The line should be IF Score > 90 THEN.
Q4
B — A counted loop in a flowchart becomes FOR ... TO ... NEXT. UNTIL belongs to REPEAT. The line should be FOR Num ← 1 TO 10.
Q5
A — The Yes branch of the diamond starts after THEN, so the keyword THEN is needed at the end of the IF line. The line should be IF Age >= 18 THEN.