Cambridge A2 Level Computer Science 9618 · 20.1 Programming Paradigms

Q1 · 9618/31/M/J/21 Q9

Worked solution from the Further Programming Paper 3 Advanced Theory booklet, Part 1 of 2.

Q19618/31/M/J/21original Q9Structured · 8 marks
Question 9 from 9618/31/M/J/21

Worked solution

(a)

An imperative (procedural) language tells the computer how to do a task, step by step.

Write: Programs use variables whose values are changed by assignment statements [1]

Write: The statements are a sequence of commands carried out in the order written, often with repetition (iteration) [1]

(b)

A declarative language says what result is wanted, not how to get it.

Write: The programmer states what needs to be done instead of how to do it [1]

Write: It uses facts and rules, and queries to satisfy a goal (it can be logical or functional) [1]

(c)

Look at the style of each piece of code:

Program code exampleProgramming paradigm
male(john). female(ethel). parent(john, ethel).Declarative
FOR Counter = 1 TO 20 ... NEXT CounterProcedural / imperative
Start: LDD Counter, INC ACC, STO CounterLow-level / assembly
public class Vehicle { ... }Object-oriented (OOP)

Facts written as male(john). is declarative [1]

A FOR loop with assignment is procedural / imperative [1]

LDD, INC and STO instructions are low-level (assembly language) [1]

A class with private data and a constructor is object-oriented [1]

KEY IDEAImperative code gives step-by-step commands, declarative code states facts and goals, low-level code uses processor instructions and OOP is built on classes.
TOTAL 8 marks

Official mark scheme

Mark scheme for 9618/31/M/J/21 question 9
VIDEO
▶ Topic lesson

A lesson on this topic · by Craig'n'Dave. Tap the picture to open it on YouTube.

Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.