Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

THE SCIENCE SCHOOL

Computer Science
Class 9th –Worksheet-2
1st June, 2021
Name: ______________________ Date: ______________

Q.1 Explain what a compiler does and what an interpreter does. In your explanation
include a description of the differences between them.

Compiler: A compiler is a type of translator that translates a high level language code into
machine code and creates an executable file for it. A compiler translates everything at once
and does not present any errors during compilation, rather at the end of compilation. A
compiler is also required to create programs without revealing the source code. It is
different from interpreters as you only have to compile a program once.

Interpreter: An interpreter is a type of translator that translates a high level language code
into machine code to be ran. An interpreter translates line by line and presents any errors
during translation, rather than the end of translation. An interpreter is not suitable for
translating distributive programs as it reveals the source code. It is different from compilers
as the program needs to be translated every time the program needs to be run, making it
inefficient for users, however better for development.

Q.2 Choose which type of translator you would use to develop a program written in a high-
level programming language. Give three reasons to support your choice.

I would use an interpreter to develop a program written in a high level programming


language as it allows errors to be logged easily during translation, improving time
management and productivity. As a program is being developed, there is a need of
debugging and correction every once in a while and it would be tedious to compile it into
an executable file every time something needs to be tested. Furthermore, the source code
is visible to us and we are not distributing the program during development, therefore we
also do not need to use compilers.

Q.3 Six statements about assembly language are shown.

Tick (✓) whether the statement is true or false.








Q.4 Obaid is writing a computer program in a high-level language. He needs to send just the
machine code for the program to his friend, electronically. It is important that the program
is executed as quickly as possible. Identify which translator will be most suitable for Obaid
to use. Explain your choice.

Type of translator. Compiler

Explanation. A compiler creates an executable file for a program. A compiler is also


required to create programs without revealing the source code, and just the machine code
it is translated into. It has to be just compiled once and later the program can be used by
executable files, which are a lot faster to run than translating the program again.

Q.5 Many programmers write computer programs in high-level languages. The programs
need to be translated into machine code to be read by the computer. State two types of
translator that can be used.

Translator 1. Compiler

Translator 2. Translator

Q.6 Salman is writing a program using a high-level language. The program will be published
and sold for profit. Salman uses an interpreter when creating the computer program.

State three features of an interpreter.

Feature 1. It translates line by line and presents errors as they come


Feature 2. It needs to translate the code every time it has to be ran, as it does not produce
an executable file

Feature 3. It needs the source code to be able to run the program.

Q.7 Zaib has written the program and started compiling it.

Explain two benefits of compiling the program.

Benefit 1. Compilers can create an executable file after the compilation which can be easily
distributed and the source code of the program is not revealed

Benefit 2. They translate the program all at once and not line by line which is better for
performance and also does not slow down when executing loops.

Q.8 Three programmers are working on different projects:

• Salma is developing a program written in a low-level language

• Zainab is developing a program written in a high-level language

• Akbar is preparing a program written in a high-level language for sale. State, with reasons,
which type of translator each programmer should use. Each programmer should be using a
different type of translator.

Salma: Salma can use an assembler to assemble the assembly as it is the only type of
translator that is available to translate low level language. It should be fairly efficient and
faster as compared to other translators as it associates each command with a similar
command on the processor.

Zainab: Zainab should use an interpreter to develop a program written in a high level
programming language as it allows errors to be logged easily during translation, improving
time management and productivity. As a program is being developed, there is a need of
debugging and correction every once in a while and it would be tedious to compile it into
an executable file every time something needs to be tested. Furthermore, the source code
is visible to us and we are not distributing the program as it is not for sale, therefore we
also do not need to use compilers.

Akbar: A compiler creates an executable file for a program. A compiler is also required to
create programs without revealing the source code, and just the machine code it is
translated into. It has to be just compiled once and later the program can be used by
executable files, which are a lot faster to run than translating the program again.
Executable file it produces is also very easy to distribute.
Q.9 Five statements about interpreters and compilers are shown in the table below.

Study each statement.

Tick (✓) to show whether the statement refers to an interpreter or to a compiler.






Q.10 Complete the following by writing either compiler, interpreter or assembler in the
spaces provided.

Compiler – translates source code into object code.

Assembler – translates low-level language into machine code.

Interpreter – stops the execution of a program as soon as it

You might also like