Programming
Programming
4 For each of the four groups of statements in the table, place a tick in the correct column to
show whether it is an example of Selection or Repetition.
[4]
2 Describe each of the following data types used in programming. In each case, give an
example of a piece of data to illustrate your answer. Each example must be different.
Char
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
String
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Boolean
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[6]
[4]
June 2019 Paper 23, question 5
5 Identify and describe three loop structures that are available in pseudocode.
5 A programmer writes a program to weigh baskets of fruit in grams, keeping a total of the
weight and counting the number of baskets. The total weight is stored in a variable Total and
the number of baskets is stored in a variable BasketCount.
Explain, including examples of programming statements, how totalling and counting could be
used in this program.
Totalling ........................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
Counting ........................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
...................................................................................................................................................[4]
Variables
..........................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
Arrays ...........................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
...................................................................................................................................................[6]
...................................................................................................................................................
...................................................................................................................................................
......................................................................................................................................[4]
4 The pseudocode algorithm shown has been written by a teacher to enter marks for the
students in her class and then to apply some simple processing.
Count ←0
REPEAT
INPUT Score[Count]
IF Score[Count] >= 70
THEN
Grade[Count] ← "A"
ELSE
IF Score[Count] >= 60
THEN
Grade[Count] ← "B"
ELSE
IF Score[Count] >= 50
THEN
Grade[Count] ← "C"
ELSE
IF Score[Count] >= 40
THEN
Grade[Count] ← "D"
ELSE
IF Score[Count] >= 30
THEN
Grade[Count] ← "E"
ELSE
Grade[Count] ← "F"
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
Count ←
Count + 1
UNTIL Count = 30
(b) Write the pseudocode to output the contents of the arrays Score[] and Grade[] along with
suitable messages.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [3]
(c) Describe how you could change the algorithm to allow teachers to use it with any size of
class.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.....................................................................................................................................[3]
2 (a) Write an algorithm in pseudocode to input 500 positive whole numbers. Each number
input must be less than 1000. Find and output the largest number input, the smallest number
input and the range (difference between the largest number and smallest number).
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
......................................................................................................................................[6]
(b) Describe how the algorithm could be changed to make testing less time-consuming.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
......................................................................................................................................[2]
3 Identify a suitable validation check that could be used for each piece of normal test data and
describe how it would be used. Each validation check must be different.
Test data for entering an email address: [email protected]
(a) Identify the four errors in the pseudocode and suggest a correction for each error.
Error 1 .......................................................................................................................................
Correction .................................................................................................................................
...................................................................................................................................................
Error 2 .......................................................................................................................................
Correction .................................................................................................................................
...................................................................................................................................................
Error 3 .......................................................................................................................................
Correction .................................................................................................................................
...................................................................................................................................................
Error 4 .......................................................................................................................................
Correction .................................................................................................................................
...............................................................................................................................................[4]
http://SirRazaAcademy.com Compiled by: Syed M.Raza 9
IGCSE / O-LEVEL Computer Science TOPICAL PAST PAPERS – PROGRAMMING
[4]
(b) Using a single loop, write an algorithm in pseudocode to output 50 names that have been
stored in the array, Name[]
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
................................................................................................................................................[3]
A file
B function
C parameter
D process
[1]
A answer
B call
C parameter
D response
[1]
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
............................................................................................................................................... [3]
(b) The function Length(X) finds the length of a string X.
The function SubString(X,Y,Z) finds a substring of X starting at position Y and Z
characters long. The first character in X is in position 1.
Write pseudocode statements to:
• store the string "Programming is fun" in X
• find the length of the string and output it
• extract the word fun from the string and output it.
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
............................................................................................................................................... [6]