← IGCSE Computer Science Paper 2

Converting a 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.

Understanding Converting a flowchart to pseudocode in IGCSE Computer Science Paper 2

What it does: When the back arrow follows a diamond placed after the process, the body runs first. This is REPEAT ... UNTIL, and UNTIL ends the loop. IF, THEN, OUTPUT and ENDIF are keywords, so they are written in capitals. The closing ENDIF is added to finish the decision. A diamond is a decision, so it becomes an IF statement. The Yes and No branches become the THEN and ELSE parts. Parallelogram symbols are input or output. The word inside the symbol tells you which keyword to use. Here it is OUTPUT. A process box that stores a value becomes an assignment, written with the arrow <-. The = sign is for comparing values, not for assigning them.

Common mistakes: The diamond became an IF, so the decision must be closed with ENDIF. ENDWHILE belongs to a WHILE loop. The line should be ENDIF. Keywords must be written in capitals when converting a flowchart to pseudocode. The line should be OUTPUT Count.

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 188–213) and word search (Modules 188–231).

Take this worksheet further — free with Cloodit

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

Learning
Duo
A flowchart has a diamond that asks 'Mark >= 50?' with a Yes branch and a No branch. Which pseudocode does it become?
IF Mark >= 50 THEN ... ELSE ... ENDIFFOR Mark <- 50 TO ... NEXT Mark
Matches
IF Age >= 18 THEN OUTPUT "Adult" ELSE OUTPUT "Child"
↓
The ENDIF is missing, so the decision from the flowchart is not closed
Applying
Meanings
Term
Flowchart to pseudocode
Meaning
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.
Practice
Total ← 0
Testing
Gaps
Check Answer
Spots
3 OUTPUT "Pass"
4ENDWHILE

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

The 'Sperm Whale' badge — Deep Sea Champion, 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. 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 ✓
A diamond is a decision, so it becomes an IF statement. The Yes and No branches become the THEN and ELSE parts.
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
The test comes before the loop body, and the back arrow returns to the test. That is a WHILE loop, which can run zero times.
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 ✓
The body runs before the test, and the back arrow goes up to the start of the body. That is a REPEAT ... UNTIL loop, which always runs at least once.
4. You have turned a flowchart's decision diamond into an IF statement. What must you add at the end?
A. ENDIF ✓
B. ENDWHILE
The flowchart has no closing symbol for the decision, so you add ENDIF yourself. Every IF needs its own ENDIF.
5. A flowchart parallelogram contains the text 'Output Total'. Which line of pseudocode matches it?
A. OUTPUT Total ✓
B. INPUT Total
Parallelogram symbols are input or output. The word inside the symbol tells you which keyword to use. Here it is OUTPUT.

Match the Pairs

Diamond: Mark >= 50? Yes → OUTPUT "Pass", No → OUTPUT "Fail" → Convert the diamond into IF ... THEN ... ELSE ... ENDIF, with each branch becoming its own statement
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
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
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
IF Age >= 18 THEN OUTPUT "Adult" ELSE OUTPUT "Child" → The ENDIF is missing, so the decision from the flowchart is not closed
FOR Count ← 1 TO 5 OUTPUT Count ENDFOR → A FOR loop is closed with NEXT, not ENDFOR, so the wrong closing keyword was written

Key Term

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.

Fill in the Blanks

1. IF Mark >= 50 THEN OUTPUT "Pass" ENDIF
Hint: Type the keyword that closes a decision diamond turned into an IF statement
2. WHILE Lives > 0 DO Lives ← Lives - 1 ENDWHILE
Hint: Type the keyword for a loop where the diamond is tested first and a back arrow returns to it
3. REPEAT INPUT Guess UNTIL Guess = 7
Hint: Type the keyword that ends a loop whose decision diamond comes after the process and loops back
4. FOR Count ← 1 TO 5 OUTPUT Count NEXT Count
Hint: Type the keyword you must add to close a counted loop
5. INPUT Num Total ← Total + Num OUTPUT Total
Hint: Type the keyword for an output parallelogram in the flowchart

Spot the Error

Question 1
A INPUT Mark
B IF Mark >= 50 THEN
C OUTPUT "Pass"
D ENDWHILE
E OUTPUT "Done"
Line 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.
Question 2
A Count ← 0
B WHILE Count < 5 DO
C output Count
D Count ← Count + 1
E ENDWHILE
Line C — Keywords must be written in capitals when converting a flowchart to pseudocode. The line should be OUTPUT Count.
Question 3
A if Score > 90 THEN
B OUTPUT "Top"
C ENDIF
Line A — The decision diamond becomes an IF statement, and keywords must be in capitals. The line should be IF Score > 90 THEN.
Question 4
A Total ← 0
B FOR Num ← 1 UNTIL 10
C Total ← Total + Num
D NEXT Num
Line B — A counted loop in a flowchart becomes FOR ... TO ... NEXT. UNTIL belongs to REPEAT. The line should be FOR Num ← 1 TO 10.
Question 5
A IF Age >= 18
B OUTPUT "Adult"
C ELSE
D OUTPUT "Child"
E ENDIF
Line 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.

Student with a class code? Join your class →