IGCSE · Practice questions · Assemblers, compilers and interpreters

Translate the code.

Six original Cambridge-style questions on assemblers, compilers and interpreters, with mark-scheme solutions.

Original questions All questions on this page are original work, written in the Cambridge IGCSE style. They are not from past papers. They test the same concepts and skills the syllabus rewards.
Keep these straight

Whole or line by line.

01
Explain
[3 marks]

Describe how a compiler translates a high-level language program and how it reports errors.

  • It translates the whole program at once, before it is executed. ✓
  • It produces an executable file (machine code). ✓
  • If errors are detected it produces an error report for the whole code (and no executable). ✓
02
Explain
[3 marks]

Describe how an interpreter translates a high-level language program and how it reports errors.

  • It translates one line of code and then executes it, ✓
  • before moving on to the next line (line by line). ✓
  • It stops execution when an error is found and reports that error. ✓
03
Recall
[2 marks]

State the type of translator needed for: (a) a program written using mnemonics such as LDD and ADD; (b) a program written in Python that is to be sold as an executable file.

  • (a) Assembler. ✓
  • (b) Compiler. ✓
04
Explain
[4 marks]

Give two advantages of a compiler and two advantages of an interpreter.

  • Compiler: produces an executable file that runs without the translator / runs faster once compiled. ✓
  • Compiler: the source code is not given to users, so it cannot easily be copied or changed. ✓
  • Interpreter: stops at the error, so it is easy to see where the error is. ✓
  • Interpreter: code can be tested line by line / in parts during development, without translating the whole program. ✓
05
Apply
[2 marks]

A programmer uses an interpreter while writing an app and a compiler when the app is finished. Explain why.

  • During development an interpreter helps debugging, because it stops at each error and parts of the code can be tested as they are written. ✓
  • When finished, a compiler produces an executable file to distribute, which runs quickly without the source code or a translator. ✓
06
Analysis
[2 marks]

A program is run with an interpreter. It outputs two lines and then stops with an error message. When the same program is compiled, nothing is output at all. Explain the difference.

  • The interpreter executed the lines before the error, producing output, then stopped at the error. ✓
  • The compiler translates the whole program first; because there is an error no executable is produced, so nothing runs and only an error report is given. ✓

Mark this once you have attempted all six and checked your working. It records a Practiced badge on the topic and adds a one-time bonus. Revealing the solutions alone does not count.