1.3.7 High - and Low-Level Languages and Their Translators PDF

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

CAMBRIDGE COMPUTER SCIENCE AHMED THAKUR

OL COMPUTER SCIENCE – 2210/01 TOPICAL PAST PAPERS


1.1 INFORMATION REPRESENTATION

Q1 2016-Nov, P13

6 High-level or low-level languages can be used when writing a computer program.

State two advantages of using a high-level language and two advantages of using a low-level language.

High-level language advantage 1 ..............................................................................................................

...................................................................................................................................................................

High-level language advantage 2 ..............................................................................................................

...................................................................................................................................................................

Low-level language advantage 1...............................................................................................................

...................................................................................................................................................................

Low-level language advantage 2 …………………...........................................................................................

............................................................................................................................................................. [4]

AHMED THAKUR https://www.facebook.com/groups/OAComputers/ Page 1


[email protected], 0300-8268885
CAMBRIDGE COMPUTER SCIENCE AHMED THAKUR

OL COMPUTER SCIENCE – 2210/01 TOPICAL PAST PAPERS


1.1 INFORMATION REPRESENTATION

8 Four descriptions about compilers and interpreters are shown below.

Q2 2016-Nov, P12

1 (a) Give two reasons why a programmer would choose to write code in a low-level language.

1 .....................................................................................................................................................

.........................................................................................................................................................

.........................................................................................................................................................

2 .....................................................................................................................................................

.........................................................................................................................................................

.................................................................................................................................................... [2]

(b) High-level languages require either an interpreter or a compiler to translate the program.

AHMED THAKUR https://www.facebook.com/groups/OAComputers/ Page 2


[email protected], 0300-8268885
CAMBRIDGE COMPUTER SCIENCE AHMED THAKUR

OL COMPUTER SCIENCE – 2210/01 TOPICAL PAST PAPERS


1.1 INFORMATION REPRESENTATION

The table below lists a number of statements about language translators.

Tick (3) to show which statements refer to interpreters and which refer to compilers.

Statements Interpreter (3) Compiler (3)


Translates the source code into machine code all
at once

Produces an executable file in machine code

Executes a high-level language program one


instruction at a time
Once translated, the translator does not need to
be present for the program to run

An executable file is produced

Q3 2015-June, P12

9 (a) 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.
Statement Interpreter Compiler

creates an executable file that runs directly on the


computer

more likely to crash the computer since the machine code


produced runs directly on the processor

easier to debug since each line of code is analysed and


checked before being executed

slow speed of execution of program loops

it is more difficult to modify the executable code, since it


is in machine code format

(b) State why a compiler or an interpreter is needed when running a high-level program on a
computer.

.........................................................................................................................................................

.........................................................................................................................................................

AHMED THAKUR https://www.facebook.com/groups/OAComputers/ Page 3


[email protected], 0300-8268885
CAMBRIDGE COMPUTER SCIENCE AHMED THAKUR

OL COMPUTER SCIENCE – 2210/01 TOPICAL PAST PAPERS


1.1 INFORMATION REPRESENTATION

.....................................................................................................................................................[1]

(c) Give one benefit of writing a program in a high-level language.

.........................................................................................................................................................

.........................................................................................................................................................

.....................................................................................................................................................[1]

(d) Give one benefit of writing a program in a low-level language.

.........................................................................................................................................................

.........................................................................................................................................................

.....................................................................................................................................................[1]

(e) Study the following three sections of code.

A: 1 0 1 0 1 1 0 1
1 1 0 0 1 1 1 0
1 0 1 1 0 1 1 1

B: LDA X
INC X
STA Y

C: FOR x ← 1 TO 10
READ n
ENDFOR

Identify, using the letters A, B or C, which of the above codes is an example of assembly code,
high-level language code or machine code:

Assembly code ................................................................................................................................

High-level language code ................................................................................................................

Machine code .............................................................................................................................[2]

AHMED THAKUR https://www.facebook.com/groups/OAComputers/ Page 4


[email protected], 0300-8268885
CAMBRIDGE COMPUTER SCIENCE AHMED THAKUR

OL COMPUTER SCIENCE – 2210/01 TOPICAL PAST PAPERS


1.1 INFORMATION REPRESENTATION

Q4 2015-June, P11

10 Five statements about interpreters and compilers are shown in the table below.

Study each statement.

Tick ( ) to show whether the statement

Statement Interpreter Compiler

takes one statement at a time and executes it

generates an error report at the end of translation of the


whole program
stops the translation process as soon as the first error is
encountered

slow speed of execution of program loops

translates the entire program in one go

Q5 2012-June,P12

13 Look at these two pieces of code:

A: CLC B: FOR Loop = 1 TO 4


LDX #0 INPUT Number1, Number2
loop: LDA A,X Sum = Number1 + Number2 ADC B,X PRINT Sum
STA C,X NEXT
INX CPX #16
BNE loop

(a) Which of these pieces of code is written in a high-level language?

……………………………………………………………………………………………………………………………………………… [1]

(b) Give one benefit of writing code in a high-level language.

……………………………………………………………………………………………………………………………………………………

……………………………………………………………………………………………………………………………………………………

……………………………………………………………………………………………………………………………………………………

……………………………………………………………………………………………………………………………………………… [1]

AHMED THAKUR https://www.facebook.com/groups/OAComputers/ Page 5


[email protected], 0300-8268885
CAMBRIDGE COMPUTER SCIENCE AHMED THAKUR

OL COMPUTER SCIENCE – 2210/01 TOPICAL PAST PAPERS


1.1 INFORMATION REPRESENTATION

(c) Give one benefit of writing code in a low-level language.

……………………………………………………………………………………………………………………………………………………

……………………………………………………………………………………………………………………………………………………

……………………………………………………………………………………………………………………………………………………

……………………………………………………………………………………………………………………………………………… [1]

(d) High-level languages can be compiled or interpreted.

Give two differences between a compiler and an interpreter.

1 …………………………………………………………………………………………………………………………………………………

……………………………………………………………………………………………………………………………………………………

2 …………………………………………………………………………………………………………………………………………………

……………………………………………………………………………………………………………………………………………… [2]

Q6 2011-June,P12
7 (a)
1 h = 0
2 c = 0
3 REPEAT
4 READ x
5 IF x > h THEN x = h
6 c = c + 1
7 PRINT h
8 UNTIL c < 20

There are THREE errors in this code.

(b) The above code is an example of a high-level language.

Give TWO features of a high-level language.

1 …………………………………………………………………………………………………………………………………………………

……………………………………………………………………………………………………………………………………………………

2 …………………………………………………………………………………………………………………………………………………

……………………………………………………………………………………………………………………………………………… [2]

AHMED THAKUR https://www.facebook.com/groups/OAComputers/ Page 6


[email protected], 0300-8268885
CAMBRIDGE COMPUTER SCIENCE AHMED THAKUR

OL COMPUTER SCIENCE – 2210/01 TOPICAL PAST PAPERS


1.1 INFORMATION REPRESENTATION

(c) The code is to be interpreted rather than compiled.

Give ONE difference between these two methods.

1 …………………………………………………………………………………………………………………………………………………

……………………………………………………………………………………………………………………………………………… [1]

Q7 2010-June, P11

10 (a) Compilers and interpreters translate high-level languages. Give two differences between
compilers and interpreters.

1 …………………………………………………………………………………………………………………………………………………

……………………………………………………………………………………………………………………………………………………

2 …………………………………………………………………………………………………………………………………………………

……………………………………………………………………………………………………………………………………………… [2]

(b) Programs can be written using high-level or low-level languages.

Give one advantage of using each method.

High-level language advantage …………………………………………………………………………………………….……

…………………………………………………………………………………………………………………………………………………..

Low-level language advantage advantage …………………………………………………………………………….……

……………………………………………………………………………………….…………………………………………………….. [2]

(c) What is meant by top-down design when developing new software?

…………………………………………………………………………………………………………………………………………………..

…………………………………………………………………………………………………………………………………………………..

……………………………………………………………………………………………………………………………………………… [1]

AHMED THAKUR https://www.facebook.com/groups/OAComputers/ Page 7


[email protected], 0300-8268885

You might also like