← IGCSE Computer Science Paper 1

Compiler

A translator that converts a whole high-level language program into machine code in one go, before the program is run. The machine code can then run without the source code.

Understanding Compiler in IGCSE Computer Science Paper 1

What it does: The translation of all the code happens first and the running happens afterwards, which is how a compiler works. Both are translators, but a compiler works on high-level language and an assembler works on assembly language. Translation is finished before execution starts. The program then runs from the machine code. The source code is not needed to run the compiled result, so it can be given to users without sharing the source code. The machine code is a separate translated file, so running it does not need the original source code.

Common mistakes: An assembler translates assembly language, not a high-level program. A high-level program needs a compiler, so the line should be exe <- COMPILE(source). The source file is not machine code, so it cannot be run directly. After compiling, the program must run the executable: RUN "calc.exe".

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 430–439) and word search (Modules 419–439).

Take this worksheet further — free with Cloodit

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

Learning
Duo
A compiler translates a high-level program...
All at once, as a whole, before the program runsOne line at a time while the program runs
Matches
A compiler translates and runs the program one line at a time
↓
This describes an interpreter, not a compiler. A compiler translates the whole program before it runs.
Applying
Meanings
Term
compiler
Meaning
A translator that converts a whole high-level language program into machine code in one go, before the program is run. The machine code can then run without the source code.
Practice
// Compiler: translate ALL code first
Testing
Gaps
source code -> -> machine code
Check Answer
Spots
1INPUT source
2exe <- ASSEMBLE(source)

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

The 'Thorny Devil' badge — Detail Master, 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 compiler translates a high-level program...
A. All at once, as a whole, before the program runs ✓
B. One line at a time while the program runs
A compiler translates the whole program into machine code first. Translating line by line during running is what an interpreter does.
2. What does a compiler produce from a high-level language program?
A. Another high-level program
B. Machine code ✓
A compiler converts high-level source code into machine code that the processor can execute.
3. When does the compiler's translation happen?
A. Before the program is executed ✓
B. While the program is being executed
Translation is finished before execution starts. The program then runs from the machine code.
4. Once a program has been compiled, the student wants to run it on another computer of the same type. What is needed?
A. Only the compiled machine code (executable file) ✓
B. The source code and the compiler
The source code is not needed to run the compiled result, so it can be given to users without sharing the source code.
5. Which translator converts assembly language into machine code?
A. Compiler
B. Assembler ✓
An assembler translates low-level assembly language. A compiler translates high-level language programs.

Match the Pairs

compiler → A translator that converts a whole high-level program into machine code before the program is run
source.c -> compiler -> program.exe → The compiler translates all the source code into an executable file, which can run without the source code
A compiler translates the whole program in one go, before any of it is run → compile(whole_program) THEN run(machine_code)
A compiler turns high-level code into machine code, but an assembler turns assembly language into machine code → compiler: high-level -> machine code; assembler: assembly -> machine code
A compiler translates and runs the program one line at a time → This describes an interpreter, not a compiler. A compiler translates the whole program before it runs.
The program only works if the source code is kept with the compiled file → The compiled machine code can run on its own. The source code is not needed to run it.

Key Term

compiler
A translator that converts a whole high-level language program into machine code in one go, before the program is run. The machine code can then run without the source code.

Fill in the Blanks

1. source code -> compiler -> machine code
Hint: Type the name of the translator that sits between the source code and the machine code.
2. high-level program -> compiler -> machine code
Hint: Type what the compiler produces as its output.
3. compile(source) delete(source) run(program_exe)
Hint: Type the action performed on the finished executable file; the source code is no longer needed for it.
4. compiler: translates all of the code at once
Hint: Type the word describing how much of the program a compiler translates in one go.
5. compiler input: high-level language
Hint: Type the level of language a compiler translates; this is different from an assembler, which uses assembly language.

Spot the Error

Question 1
A INPUT source
B exe <- ASSEMBLE(source)
C SAVE exe AS "game.exe"
D RUN "game.exe"
Line B — An assembler translates assembly language, not a high-level program. A high-level program needs a compiler, so the line should be exe <- COMPILE(source).
Question 2
A source <- READ "calc.txt"
B exe <- COMPILE(source)
C SAVE exe AS "calc.exe"
D RUN "calc.txt"
Line D — The source file is not machine code, so it cannot be run directly. After compiling, the program must run the executable: RUN "calc.exe".
Question 3
A timing <- "before running"
B needs_source <- FALSE
C whole_program <- FALSE
Line C — A compiler translates the whole program in one go. whole_program should be TRUE, not FALSE.
Question 4
A input <- "machine code"
B translator <- "compiler"
C output <- "machine code"
Line A — A compiler takes high-level source code as its input and produces machine code as its output. Machine code is the output, not the input.
Question 5
A source <- LOAD "app.src"
B exe <- COMPILE(source[1])
C SAVE exe AS "app.exe"
Line B — A compiler translates the whole program at once, not just one line. It should be exe <- COMPILE(source).

Student with a class code? Join your class →