Types of Programming Language (OCR A Level Computer Science): Exam Questions

1 hour10 questions
19 marks

A computer uses a stack data structure, implemented using an array, to store numbers entered by the user.

The array is zero based and has 100 locations.

The program is amended to include the use of several queue data structures.

Discuss the use of object-oriented programming and procedural programming to create and manipulate the queue data structures.

You should include the following in your answer:

  • the features of object-oriented programming

  • the features of procedural programming

  • the benefits of using object-oriented instead of procedural programming when creating several queue structures.

Did this page help you?

21 mark

A charity uses a desktop computer to record financial donations that it receives. The computer contains a single core, 2.4GHz processor with 2MB cache.

Fig. 1 shows assembly code written using the Little Man Computer (LMC). The program calculates and outputs the total amount that is donated to the charity in any particular day. Depending on the amount, an additional bonus may be added to each amount donated.

Assembly language code snippet with labels: start, nobonus, bonus; includes actions like INP, SUB, ADD, OUT, BRA, with variables hundred, twenty, donation.

Write LMC code that will reset the value of the memory location labelled total to zero and then stop the program.

Did this page help you?

312 marks

In assembly language, different modes of addressing memory can be used.

Discuss the different modes used. You should include:

  • How the operand value is determined

  • What an operand of 27 would refer to in that mode

  • The reasons for requiring multiple modes of addressing

Did this page help you?

45 marks

The table below shows the Little Man Computer instruction set.

Mnemonic

Instruction

ADD

Add

SUB

Subtract

STA

LDA

Load

Branch always

BRZ

BRP

INP

Input

OUT

Output

End program

Complete the table above to show the missing mnemonics and instructions

Did this page help you?

54 marks

A team of programmers create a robot that will be used in a factory. The robot will be able to do the work of multiple humans.

The programmers discuss whether to write the instructions for the robot in assembly language or a high-level language.

Describe two differences between assembly language and high-level languages.

Did this page help you?

64 marks

A text-based computer game allows a user to dig for treasure on an island. The island is designed as a grid with 10 rows and 20 columns to store the treasure. Each square is given an x and y coordinate. Some of the squares in the grid store the name of a treasure object. Each treasure object has a value, e.g. 100 and a level, e.g. "Bronze."

Describe two benefits of using an object-oriented paradigm rather than a procedural paradigm.

Did this page help you?

73 marks

Fig. 1 shows assembly code written using the Little Man Computer (LMC). The program calculates and outputs the total amount that is donated to the charity in any particular day. Depending on the amount, an additional bonus may be added to each amount donated.

Logic program using assembly-style language with operations like INP, STA, SUB, BRP, LDA, ADD, OUT, and data declarations: hundred, twenty, donation, total.

Fig. 1

The program shown in Fig. 1 is run once using three different inputs. Therefore, while the program is running once, it will output the updated total three times.

Give the total values that are output when the values 10, 50 and 120 are input into this program.

Did this page help you?

86 marks

The table below shows the Little Man Computer instruction set.

Mnemonic

Instruction

ADD

Add

SUB

Subtract

STA

LDA

Load

Branch always

BRZ

BRP

INP

Input

OUT

Output

End program

Write a program using the Little Man Computer instruction set that will allow a user to input two numbers and then output the larger of the two numbers. The program should loop continuously.

Did this page help you?

912 marks

Procedural programming and object-oriented programming are two paradigms commonly used by programmers when developing computer games.

Discuss the advantages of using object-oriented programming over procedural programming when developing computer games.

You should refer to inheritance, encapsulation and polymorphism in your answer.

Did this page help you?

104 marks

A program written using the Little Man Computer instruction set is shown in Fig. 1.

Assembly language code snippet with operations for input, storing, loading, branching, and output. Includes labels such as "main" and "notpos."

Complete the table below to show the output(s) from this program given the inputs.

Inputs

Output(s)

12, 5

18, 2

16, 4

3, 7

Did this page help you?