You are on page 1of 12

Cambridge IGCSE™ and O Level Computer Science

Practice Paper 2B – Algorithms, Programming and Logic

Time allowed: 2 hours 15 minutes Maximum number of marks: 100


Answer all questions
1 In this question you will be given a statement followed by four possible answers. Select which of the
four answers you think is correct and tick (✓) the box next to your answer.
a) What is the symbol for NOT?

b) Which of these statements describes the coding stage of the program development
lifecycle?

Investigating to provide the specification of what a program is required to


do

Testing of the program to make sure that it works under all conditions

Writing of the program or suite of programs

Using the program specification to show to how the program should be


developed

c) Which statement is used for iteration?

NEXT

PROCEDURE

DECLARE

CASE

Cambridge IGCSE™ and O Level Computer Science Second Edition Study and Revision Guide 1
© Hodder & Stoughton Ltd 2022
Cambridge IGCSE™ and O Level Computer Science

d) Which statement describes a database primary key?

A collection of fields about the same item

A collection of related records

A field that uniquely identifies a record

A single piece of data

[4]
2 a) i) Describe what is meant by validation.

[2]
a) ii) A presence check is a validation check. Give three other examples of validation checks.

[3]
b) Describe, using an example, how verification is used.

[3]

Cambridge IGCSE™ and O Level Computer Science Second Edition Study and Revision Guide 2
© Hodder & Stoughton Ltd 2022
Cambridge IGCSE™ and O Level Computer Science

3 These methods are used to design a solution to a problem:


o structure diagram
o flowchart
o pseudocode
Problem: finding the cost to send a parcel.
The weight of parcel is input and if it is less than 10 grams or greater than 10,000 grams, the parcel is
rejected. Parcels weighing less than 250 grams are small, parcels weighing between 250 and 2500
grams are medium and parcels over 2500 grams are large. Small parcels cost $1.00 to send, medium
parcels cost $3.00 to send and large parcels cost $5.00 to send.
Construct a solution to this problem using each method.
a) Structure chart

[4]
b) Flowchart

[6]

Cambridge IGCSE™ and O Level Computer Science Second Edition Study and Revision Guide 3
© Hodder & Stoughton Ltd 2022
Cambridge IGCSE™ and O Level Computer Science

c) Pseudocode

[6]
4 Choose the correct words to complete this paragraph about creating a maintainable program. Not all
words will be used.

comments constants function identifiers language program


procedure syntax variables

In order to be able to maintain a ……………………….. it needs to be easily understood by other programmers.


All the ……………………….. used in the program should have meaningful names. For example, when declaring
…………………….. and ……………………….. Any code reused in the program should be part of a ………………………..
or a ……………………….. The programmer should include ……………………….. to explain how the solution works
and the ……………………….. used.
[8]

Cambridge IGCSE™ and O Level Computer Science Second Edition Study and Revision Guide 4
© Hodder & Stoughton Ltd 2022
Cambridge IGCSE™ and O Level Computer Science

5 This flowchart represents an algorithm.

a) State the purpose of the algorithm.

[1]
b) Complete the trace table for the algorithm using this data:
20, 30, 55, 65, -10, -999, 27, 30.5
X Y Z W OUTPUT

[4]

Cambridge IGCSE™ and O Level Computer Science Second Edition Study and Revision Guide 5
© Hodder & Stoughton Ltd 2022
Cambridge IGCSE™ and O Level Computer Science

c) Suggest meaningful names for:

Z
[2]
6 Write an algorithm in pseudocode to input 24 temperature readings into an array. All the readings must
be stored in the array but warnings of “too high” and “too low” must be output if the reading is above
30 or below 20. Use the array Temperature[1:24].

[6]

Cambridge IGCSE™ and O Level Computer Science Second Edition Study and Revision Guide 6
© Hodder & Stoughton Ltd 2022
Cambridge IGCSE™ and O Level Computer Science

7 In the following diagram, four descriptions are shown on the left and five statements are shown on the
right.
By drawing lines, connect each description to the appropriate statement(s). Statements might not be
used or could be connected to one or more descriptions.

[4]
8 Read this section of pseudocode that inputs fifty (50) numbers and stores them in an array
StoredNumber[1:50]. Only numbers between 0 and 100 can be stored, all others are rejected.

01 For Index  0 TO 100

02 REPEAT

03 INPUT Number

04 WHILE Number >= 0 OR Number <= 50

05 StoredNumber[Index]  Number

06 Index  Index + 1

07 NEXT Number

There are six errors in this code, some lines have more than one error. Locate these errors and suggest a
corrected piece of code for each error.

Cambridge IGCSE™ and O Level Computer Science Second Edition Study and Revision Guide 7
© Hodder & Stoughton Ltd 2022
Cambridge IGCSE™ and O Level Computer Science

[6]
9 A database of houses to rent, HouseRent, is to be set up to store the following data:
o Type of House – for example, town house, bungalow and so on
o Number of Bedrooms – for example, 4
o Number of Bathrooms – for example, 2
o Address of House – for example, 94 The Heights
o If there is a garage
o Price per calendar month of rent – for example $250.00

a) Give each field a suitable name and data type, explain why you have chosen each data type.

[6]

Cambridge IGCSE™ and O Level Computer Science Second Edition Study and Revision Guide 8
© Hodder & Stoughton Ltd 2022
Cambridge IGCSE™ and O Level Computer Science

b) Identify another field that you could use for the primary key. Give the field an appropriate name
and data type. Show an example and explain why you used that field.

Name:

Data type:

Example:

Reason for use:

[4]
c) Complete this SQL script using your field names to display the type of house, address and
price of rent per calendar month of all houses that have a garage.

SELECT

FROM

WHERE
[4]
10 At a traffic intersection there are three lights red (R), orange (O) and green (G). If a light is on then the
input is set to 1, for example R=1 means that the red light is on. Traffic (T) can move only when green is
on, and all other lights are off or both red and orange are on and green is off.
a) Write the logic expression for this problem.

T=

[4]
b) Complete the truth table for this logic expression.
Inputs Working space Output
R O G T
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
[4]

Cambridge IGCSE™ and O Level Computer Science Second Edition Study and Revision Guide 9
© Hodder & Stoughton Ltd 2022
Cambridge IGCSE™ and O Level Computer Science

c) Draw a logic circuit for the un-simplified logic expression. Each logic gate must have a
maximum of two inputs.

[6]
11 A times table test will be set up. Before using the test, the user can set the times table to be tested and
the number of questions to be asked. The times tables can be any whole number between 2 and 12
inclusive. The number of questions can be between 5 and 10 inclusive. No questions can be the same in
any test. The name of the user should be displayed with all messages and prompts.
Write and test a program that meets the following requirements:
o Sets up the starting conditions for the test
o During the test:
o displays each question with the question number
o checks if the answer input is correct and displays the right answer if the answer input was
wrong
o adds one to the user’s total every time an answer is right.
o At the end of the test:
o displays the result
o asks the user if they want a retest.
You must use pseudocode or program code and add comments to explain how your code works. All
inputs and outputs must contain suitable messages.

Cambridge IGCSE™ and O Level Computer Science Second Edition Study and Revision Guide 10
© Hodder & Stoughton Ltd 2022
Cambridge IGCSE™ and O Level Computer Science

Cambridge IGCSE™ and O Level Computer Science Second Edition Study and Revision Guide 11
© Hodder & Stoughton Ltd 2022
Cambridge IGCSE™ and O Level Computer Science

[14]

Cambridge IGCSE™ and O Level Computer Science Second Edition Study and Revision Guide 12
© Hodder & Stoughton Ltd 2022

You might also like