0% found this document useful (0 votes)
94 views5 pages

Tutorial 7.0 (C) 2 Hours

The document discusses different types of language translators: 1. Compilers translate the entire source program into machine language before executing it. 2. Interpreters translate one instruction of the source program at a time into machine language and then immediately execute it. 3. Assemblers convert program written in assembly language to machine code.

Uploaded by

Grace Merelda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
94 views5 pages

Tutorial 7.0 (C) 2 Hours

The document discusses different types of language translators: 1. Compilers translate the entire source program into machine language before executing it. 2. Interpreters translate one instruction of the source program at a time into machine language and then immediately execute it. 3. Assemblers convert program written in assembly language to machine code.

Uploaded by

Grace Merelda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

TUTORIAL 7.

0: INTRODUCTION TO PROGRAMMING
LO : c) Differentiate types of language translators (compiler, interpreter and assembler)
(2 Hours)

Answer all the questions.

1. A translator is a programming language processor that converts a computer program from one language to
another.
Identify the translator based on the statement given. [3 marks]
Statement Translator
Convert one instruction of the source program at a time into machine Interpreter
language and then immediately executed by the computer or mobile.
Converts the entire source program into machine language before executing Compiler
it.
Converts program written in assembly language to machine code. Assembler

2. A translator is a programming language processor that converts a computer program from one language to
another. Answer the following question based on Figure 1 below.

Figure 1
State the appropriate X and Y. [2 marks]
X: Compiler
Y: Interpreter

3. a) Identify X shown in Figure 2. [1 mark]

Figure 2
X: Translator
b) State the function of X in 3a). [2 marks]

=Converts instructions written in one programming language to be translated to machine


language.
PAST YEAR QUESTIONS

UPS SC025 SESI 2011/2012

1. Identify the appropriate type of translator based on the given description of the translator function. [3 marks]

Function Type of translator

Translates one high-level program instruction at a time into Interpreter


machine code.
Converts programs written in assembly language to machine Assembler
code.
Translates the entire source program into object program. Compiler

UPS SC025 SESI 2012/2013

2. Figure 1 shows three different program segments written using different types of programming languages.

Program1 Program2 Program3

if (sales > 1000) Add R1, R2 1100 0101

cout<< “Bonus paid”; Add R2, R3 1010 1111

Figure 1
Name the translator used to convert Program2 into executable codes. [1 mark]
=Interpreter

UPS SC025 SESI 2013/2014


3. Programming Language can be classified into two categories, Low Level Language and High Level
Language.

Name the translator that can be used to translate the programming language Q. [2 marks]
=Interpreter

UPS SC025 SESI 2015/2016

4. Describe the function for each of the translators listed below. [2 marks]

Compiler Translates an entire program written in high level language into an equivalent program in
machine language
Interpreter Translates a program’s statements line by line at a time written in high level language into an
equivalent program in machine language
UPS DC045 SESI 2014/2015
5. A programming language is a formal language designed to communicate with a machine, particularly a
computer.
a) Programs written in a high-level language can be compiled or interpreted.
(i) Define a compiler. [1 mark]
=A program that translates an entire program written in high level language into an equivalent
program in machine language
(ii) Define an interpreter. [1 mark]
=A program that translates a program statements line by line at a time written in high level
language into an equivalent program in machine language

b) Identify the type of translators that can convert the assembly instructions into machine code.[1 mark]
=Assembler

UPS DC045 SESI 2016/2017


6. Identify the type of translator based on the given description. [3 marks]

No. Description Type of Translator


(i) A translator that points out your error as you run the high-
level language program.
(ii) A translator that translates high-level language program
into machine code, if it is error free.
(iii) A translator that translates low-level
language program into machine code.

PSPM DC045 SESI 2012/2013


7. Programming languages are used by programmers to develop software or computerized systems.
a) List one (1) difference between compiled-languages and interpreted languages. [2 marks]
Compiled Language Interpreted Language

PSPM DC045 SESI 2016/2017


8. Programming languages are used by programmers to develop software or computerized system.
a) Describe the function of interpreter. [2 marks]

PSPM SC025 SESI 2017/2018


9. FIGURE 2 shows three program segments written in three different languages. The programs calculate
the sum of X and Y and put the value into Z.

Figure 2

a) State the translator needed to convert the program:


(i) from FIGURE 2(a) to FIGURE 2 (c) [1 mark]
(ii) from FIGURE 2(b) to FIGURE 2(c) [1 mark]
PSPM SC015 2018/2019
10. Figure 3 shows the program segments of three different languages that have been used to calculate the
sum of two numbers.

Figure 3

Identify and state the type of translator that translates the following program. State ‘None’ if a translator is
not relevant. [3 marks]
Program Type of translator
Program A to Program B Interpreter
Program C to Program A Compiler
Program C to Program B Compiler

11. There are three types of translator which are key processes in computer programming.
a) Distinguish between assembler and compiler. [4 marks]
=Assembler translates a program statements written in assembly language into an equivalent
program in machine language while compiler translates an entire program statements written
in high level into an equivalent program in machine language.
b) [3 marks]
Name and describe the third type of translator.

=Interpreter. A program that translates a program statements line by line at a time written
in high level language into an equivalent program in machine language

PSPM SC015 2019/2020


12. Based on the given items, classify the most appropriate type of language translator.

Item Type of Language Translator


Microsoft Visual Studio Compiler
Python Interpreter
Macros Assembler
C++ Compiler
BASIC Interpreter

PSPM SC015 2020/2021

13. Classify a suitable programming language paradigm based on the given description. [3 marks]

Description Programming Language Paradigm

The program statements that express facts and rules Logic programming
about problem within a formal logic system.

The program consists of routines, subroutines or Procedural programming


functions to carry out a series of computational steps.
A program that uses object that include both data and Object-oriented programming
function.

You might also like