0% found this document useful (0 votes)
20 views16 pages

Cambridge IGCSE: Computer Science 0478/21

The document is an examination paper for the Cambridge IGCSE Computer Science course, specifically Paper 2 on Algorithms, Programming, and Logic, scheduled for May/June 2023. It includes instructions for candidates, a total of 75 marks, and various questions covering topics such as program development life cycle, data validation, pseudocode, algorithms, and database queries. The paper consists of multiple sections requiring candidates to demonstrate their understanding of computer science concepts and problem-solving skills.

Uploaded by

gautam.mahesh
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)
20 views16 pages

Cambridge IGCSE: Computer Science 0478/21

The document is an examination paper for the Cambridge IGCSE Computer Science course, specifically Paper 2 on Algorithms, Programming, and Logic, scheduled for May/June 2023. It includes instructions for candidates, a total of 75 marks, and various questions covering topics such as program development life cycle, data validation, pseudocode, algorithms, and database queries. The paper consists of multiple sections requiring candidates to demonstrate their understanding of computer science concepts and problem-solving skills.

Uploaded by

gautam.mahesh
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/ 16

Cambridge IGCSE™

* 4 8 1 6 0 2 0 7 0 1 *

COMPUTER SCIENCE 0478/21


Paper 2 Algorithms, Programming and Logic May/June 2023

1 hour 45 minutes

You must answer on the question paper.

No additional materials are needed.

INSTRUCTIONS
● Answer all questions.
● Use a black or dark blue pen. You may use an HB pencil for any diagrams or graphs.
● Write your name, centre number and candidate number in the boxes at the top of the page.
● Write your answer to each question in the space provided.
● Do not use an erasable pen or correction fluid.
● Do not write on any bar codes.
● Calculators must not be used in this paper.

INFORMATION
● The total mark for this paper is 75.
● The number of marks for each question or part question is shown in brackets [ ].
● No marks will be awarded for using brand names of software packages or hardware.

This document has 16 pages. Any blank pages are indicated.

DC (CJ/CT) 313987/4
© UCLES 2023 [Turn over
2

1 (a) Four descriptions of stages in the program development life cycle are shown.

Draw one line to link each description to its most appropriate program development life cycle
stage.

Not all program development life cycle stages will be used.

Program development life cycle description Program development life cycle stage

develop an algorithm to solve the problem analysis


by using structure diagrams, flowcharts or
pseudocode

coding

detect and fix the errors in the program


design

identify the problem and its requirements


evaluation

write and implement the instructions to


solve the problem testing
[4]
(b) Identify three of the component parts after a problem has been decomposed.

1 ................................................................................................................................................
Inputs

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

2 ................................................................................................................................................
Processes

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

3 ................................................................................................................................................
Outputs

...................................................................................................................................................
[3]

2 Tick (ü) one box to show the name of the data structure used to store a collection of data of the
same data type.

A Array

B Constant

C Function

D Variable
[1]
© UCLES 2023 0478/21/M/J/23
3

3 (a) Describe what is meant by data validation.

Data validation involves checks performed on data to ensure they are in a suitable
...................................................................................................................................................
format for the whole program - so that they can be accepted. Example includes
...................................................................................................................................................
type checks, range checks, length checks, format checks, etc.

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

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

(b) A validation check is used to make sure that any value that is input is an integer between 30
and 200 inclusive.

Give one example of each type of test data to check that the validation check is working as
intended. Each example of test data must be different.

Give a reason for each of your choices of test data.

60, 150
Normal test data .......................................................................................................................

This set of data is accepted by the program, and thus ensures that the
Reason .....................................................................................................................................
porgram is accepting all values that it should - that are within the range,
and it is working the way it is intended to.
...................................................................................................................................................

Abnormal test data ...................................................................................................................


400, -10

Reason This set of data is rejected by the program. This ensures that the values
.....................................................................................................................................
outside the range are NOT accepted, and proves the program is working as it
should
...................................................................................................................................................

Extreme test data .....................................................................................................................


30, 200

Reason Both these values are accepted. This set of data tests the program’s
.....................................................................................................................................
maximum limit of values that can be accpeted, by inputting the maximum
...................................................................................................................................................
possible and minimum possible values to see if they are accepted.
[6]

4 Explain the purpose of the library routines DIV and ROUND


DIV is used to return a whole number integer value for an integer floor division
DIV ...................................................................................................................................................
between two numbers - for example, DIV(6, 4) is equal to 1, as only the integer part
of 1.5 is taken.
..........................................................................................................................................................

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

..........................................................................................................................................................
ROUND rounds off a number to a certain no. of significant figures or decimal
ROUND ..............................................................................................................................................
points. For example, ROUND(3.1415, 2) would be equal to 3.14, as only 2
decimal places are taken.
..........................................................................................................................................................

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

..........................................................................................................................................................
[4]
© UCLES 2023 0478/21/M/J/23 [Turn over
4

5 An algorithm has been written in pseudocode to allow some numbers to be input. All the positive
numbers that are input are totalled and this total is output at the end.
An input of 0 stops the algorithm.

01 Exit 1←
02 WHILE Exit <> 0 DO
03 INPUT Number
04 IF Number < 0
05 THEN
06 Total ←
Total + Number
07 ELSE
08 IF Number = 0
09 THEN
10 Exit 1 ←
11 ENDIF
12 ENDIF
13 ENDIF
14 OUTPUT "The total value of your numbers is ", Number

(a) Identify the four errors in the pseudocode and suggest a correction for each error.

Error 1 .......................................................................................................................................
line 04 - IF Number < 0

Correction .................................................................................................................................
IF Number > 0

...................................................................................................................................................
line 10 - Exit ← 1
Error 2 .......................................................................................................................................

Exit ← 0
Correction .................................................................................................................................

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

line 13 - ENDIF
Error 3 .......................................................................................................................................
ENDWHILE
Correction .................................................................................................................................

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

Error 4 .......................................................................................................................................
line 14 - OUTPUT “The total value of your numbers is” Number
OUTPUT “The total value of your numbers is” Total
Correction .................................................................................................................................

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

© UCLES 2023 0478/21/M/J/23


5

(b) Describe how you could change the corrected algorithm to record and output how many
positive numbers have been included in the final total.

You do not need to rewrite the algorithm.

In order to record the no. of positive numbers input, you can add a count
...................................................................................................................................................
functionality below line 06, after the totalling - that says Count ← Count +1. But
before this, you must initialise the count value on top of the algorithm as Count ←
...................................................................................................................................................
0, after line 01. Then to output the count, you can add an output statement syaing
...................................................................................................................................................
OUTPUT “The total no. of positive number input is” Count.

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

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

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

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

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

6 State two features that should be included to create a maintainable program.

Give a reason why each feature should be used.

The use of procedures and functions can help in maintaining the porgam well as it
1 .......................................................................................................................................................
adds structure to the program and helps the user understand what each part of
..........................................................................................................................................................
the code does, helpinng them make tweaks and changes every now and then,
quite easily.
..........................................................................................................................................................

..........................................................................................................................................................
Comments can also be added to each part of the code to explain what exactly
2 .......................................................................................................................................................
each part does, which can help in making it easy to maintain. Now the
programmer can understand what each part does exactly by reading the
..........................................................................................................................................................
comments next to the corresponding part.
..........................................................................................................................................................

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

© UCLES 2023 0478/21/M/J/23 [Turn over


6

7 The flowchart represents an algorithm.

START

Pointer 1

INPUT
Letter

IS No
Word[Pointer, 1] Pointer Pointer + 1
= Letter ?

Yes

OUTPUT "Letter ", Letter,


" is represented by ",
Word[Pointer, 2]

OUTPUT "Another Letter?


(Y or N)"

INPUT Choice

Yes IS No
Choice = STOP
'Y' ?

© UCLES 2023 0478/21/M/J/23


7

The table represents the two-dimensional (2D) array Word[] which stores the first half of the
phonetic alphabet used for radio transmission. For example, Word[10,1] is ‘J’.

Index 1 2
1 A Alpha
2 B Bravo
3 C Charlie
4 D Delta
5 E Echo
6 F Foxtrot
7 G Golf
8 H Hotel
9 I India
10 J Juliet
11 K Kilo
12 L Lima
13 M Mike

(a) Complete the trace table for the algorithm by using the input data: F, Y, D, N

Pointer Letter Choice OUTPUT


1 F
2
3
4
5
6 Letter F Is Represented by Foxtrot
Another letter? (Y OR N)
Y
1 D
2
3
4
Letter D Is Represented by Delta
Another letter? (Y OR N)
N
[4]

© UCLES 2023 0478/21/M/J/23 [Turn over


8

(b) Identify the type of algorithm used.

This type of algorithm is searching for elements through a liear search.


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

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

(c) Describe one problem that could occur with this algorithm if an invalid character was input.

...................................................................................................................................................
The algorithm would have continued to go on without stopping as the corresponding
name would not have been found, and eventually may crash out.
...................................................................................................................................................

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

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

© UCLES 2023 0478/21/M/J/23


9

BLANK PAGE

© UCLES 2023 0478/21/M/J/23 [Turn over


10

8 The function LENGTH(Phrase)calculates the length of a string Phrase

(a) Write the pseudocode statements to:


• store the string "The beginning is the most important part" in Phrase
• calculate and output the length of the string
• output the string in upper case.

DECLARE Phrase, uppercase : STRING


...................................................................................................................................................
DECLARE length : INTEGER
...................................................................................................................................................
Phrase ← “The beginning is the most important part”
...................................................................................................................................................
length ← LENGTH(Phrase)
...................................................................................................................................................
OUTPUT “The length of the string is”, length
...................................................................................................................................................
uppercase ← UCASE(Phrase)
OUTPUT “The string in uppercase is”, uppercase
............................................................................................................................................. [3]

(b) Write the output your pseudocode should produce.

The length of the string is 40


...................................................................................................................................................
The string in uppercase is THE BEGINNING IS THE MOST IMPORTANT PART
...................................................................................................................................................

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

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

© UCLES 2023 0478/21/M/J/23


11

9 Consider this logic expression.

Z = (NOT A OR B) AND (B XOR C)

(a) Draw a logic circuit for this logic expression.

Each logic gate must have a maximum of two inputs.

Do not simplify this logic expression.

B Z

[4]

(b) Complete the truth table from the given logic expression.

Working space
A B C Z

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]

© UCLES 2023 0478/21/M/J/23 [Turn over


12

10 A database table called TVRange shows the main features and prices of a range of televisions.

TVCode ScreenSize Satellite SmartTV SoundBar Price$


TV90SaSmSd 90 YES YES YES 9750.00
TV75SaSmSd 75 YES YES YES 8500.00
TV75SaSd 75 YES NO YES 8000.00
TV65SaSmSd 65 YES YES YES 6000.00
TV65SmSd 65 NO YES YES 5000.00
TV65SaSd 65 YES NO YES 5000.00
TV55SaSmSd 55 YES YES YES 4000.00
TV55SaSd 55 YES NO YES 3500.00
TV55SmSd 55 NO YES YES 3500.00
TV50SaSmSd 50 YES YES YES 2500.00
TV50Sa 50 YES NO NO 1750.00
TV50Sm 50 NO YES NO 1750.00
TV40Sa 40 YES NO NO 1200.00
TV40 40 NO NO NO 950.00
TV32 32 NO NO NO 650.00

(a) Give the name of the field that is most suitable to be the primary key.

State the reason for this choice.

Field ..........................................................................................................................................

Reason .....................................................................................................................................

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

© UCLES 2023 0478/21/M/J/23


13

(b) The database uses the data types:


• text
• character
• Boolean
• integer
• real
• date/time.

Complete the table to show the most appropriate data type for each field.
Each data type must be different.

Field Data type


TVCode
ScreenSize
SmartTV
Price$
[2]

(c) Complete the structured query language (SQL) query to return the television (TV) code,
screen size and price of all Smart TVs in the database table.

SELECT TVCode, ......................................................., .......................................................

....................................................... TVRange

WHERE SmartTV = .......................................................;


[4]

© UCLES 2023 0478/21/M/J/23 [Turn over


14

11 A one-dimensional (1D) array Days[] contains the names of the days of the week. A
two-dimensional (2D) array Readings[] is used to store 24 temperature readings, taken once
an hour, for each of the seven days of the week. A 1D array AverageTemp[] is used to store the
average temperature for each day of the week.

The position of any day’s data is the same in all three arrays. For example, if Wednesday is
in index 4 of Days[], Wednesday’s temperature readings are in index 4 of Readings[] and
Wednesday’s average temperature is in index 4 of AverageTemp[]

The temperature readings are in Celsius to one decimal place. Temperatures can only be from
–20.0 °C to +50.0 °C inclusive.

Write a program that meets the following requirements:


• input and validate the hourly temperatures for one week
• calculate and store the average temperature for each day of the week
• calculate the average temperature for the whole week
• convert all the average temperatures from Celsius to Fahrenheit by using the formula
Fahrenheit = Celsius * 9 / 5 + 32
• output the average temperature in Celsius and in Fahrenheit for each day
• output the overall average temperature in Celsius and in Fahrenheit for the whole week.

You must use pseudocode or program code and add comments to explain how your code works.

You do not need to declare any arrays, variables or constants; you may assume that this has
already been done.

All inputs and outputs must contain suitable messages.

All data output must be rounded to one decimal place.

You will need to initialise and populate the array Days[] at the start of the program.

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

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

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

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

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

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

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

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

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

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

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

..........................................................................................................................................................
© UCLES 2023 0478/21/M/J/23
15

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

..........................................................................................................................................................
© UCLES 2023 0478/21/M/J/23 [Turn over
16

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

.................................................................................................................................................. [15]

Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the
publisher will be pleased to make amends at the earliest possible opportunity.

To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
at www.cambridgeinternational.org after the live examination series.

Cambridge Assessment International Education is part of Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge
Local Examinations Syndicate (UCLES), which is a department of the University of Cambridge.

© UCLES 2023 0478/21/M/J/23

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy