0% found this document useful (0 votes)
11 views48 pages

Chapter 7

Uploaded by

xainab800
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)
11 views48 pages

Chapter 7

Uploaded by

xainab800
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/ 48

3$*( 

3$*(

&+$37(5

3$*(
3$*(

10

4 This section of program code may be used as a validation check.

1 PRINT "Input a value between 0 and 100 inclusive"


2 INPUT Value
3 WHILE Value < 0 OR Value > 100
4 PRINT "Invalid value, try again"
5 INPUT Value
6 ENDWHILE
7 PRINT "Accepted: ", Value

(a) Give a name for this type of validation check.

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

(b) Describe what is happening in this validation check.

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

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

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

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

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

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

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

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

(c) Complete the trace table for


o this program code using the test data: 200, 300, –1, 50, 60
or

Value OUTPUT

[3]

© UCLES 2019 2210/21/M/J/19


3$*(

11

(d) Draw a flowchart to represent this section of program code.

[5]
© UCLES 2019 2210/21/M/J/19 [Turn over
3$*(

Section B

2 (a) An algorithm has been written in pseudocode to input 100 numbers, select and print the
largest number and smallest number.

Count 1
INPUT Number
High Number
Low Count
REPEAT
INPUT Number
IF Number > High
THEN
High Number
ENDIF
IF Number > Low
THEN
Low Number
ENDIF
Count Count + 1
UNTIL Count > 99
PRINT "Largest
"Largeest
s Number is ", Number
PRINT "Smallest
"Sma
mall
ma ll
lest Number is ", Low

Find the fourr error


orss in
or
errors n the
the pseudocode
pseudocode and suggest
sugg
ggest a correction for each error.

Erro
Er rorr 1 ..
ro
Error ........
. .....
.........................................
.........
. ............
....................
.........
. ..............
....
......
......
......
.......................................
........................................................................................................................................

Cor
rrectiion
rrec
rr o ..................................................................................................................................
Correction ...................................................................................................................................

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

Error 2 ................................
..........................................................................................................
........................................................................................................................................

Correction ..........................
........................................................................................................
.................................................................................................................................

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

Error 3 ........................................................................................................................................

Correction .................................................................................................................................

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

Error 4 ........................................................................................................................................

Correction .................................................................................................................................

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

© UCLES 2019 2210/22/M/J/19


3$*(

(b) Show how you would change the corrected algorithm to total the numbers and print the total.
Use a variable Total.

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

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

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

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

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

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

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

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

© UCLES 2019 2210/22/M/J/19 [Turn over


3$*(

10

3 This flowchart inputs the marks gained in an examination. An input of –1 ends the routine.

START

Total 0
Count 0
Distinction 0

INPUT Mark

Is Mark = –1 ? Yes
Total Total + Mark
Count Count + 1

No

No
o Is OUTPUT "Number of
Mark
M k >=
ark >= Dist
Di tinct
ctio
ions
Distinctions s ",
", Distinction
Dis
Di sti
inct
c ion
0?
80 OUT
OUTPUT
UT "Average
OUTPUT "Av
Aveerag
age
e Mark
Mark
rk "
Total/Count
Yes
Ye
es

Di
Distinction
n Distinction
Distinction + 1 END

Complete the trace table for the


emmark
ark input data: 50, 70, 65, 30, 95, 50, 55, 85, 65, 35, –1, 45

Total Count Distinction


Distin
nction Mark OUTPUT

[4]
© UCLES 2019 2210/22/M/J/19
3$*(

11

4 For each of the fourr groups of statements in the table, place a tick in the correct column to show
whether it is an example of Selection or Repetition.

Statements Selection Repetition


FOR A 1 TO 100
B B + 1
NEXT A
CASE A OF
100: B A
200: C A
ENDCASE
IF A > 100
THEN
B A
ENDIF
REPEAT
A B * 10
UNTIL A > 100
[4]

5 Explain what is meant byy validation


va
alida
ation and verification.
Give an example for
fo
or each
ea
ach
ch one.

Valida
atitio
Validationon ..........................................................................................................................................
............
.......................................................................................................................................

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

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

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

Example .....................................
........................................................................................................
...........................................................................................................................................

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

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

Verification ........................................................................................................................................

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

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

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

Example ...........................................................................................................................................

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

..........................................................................................................................................................
[6]

© UCLES 2019 2210/22/M/J/19 [Turn over


3$*(

Section B

2 An algorithm has been written in pseudocode to select a random number using the function
RandInt(n), which returns a whole number between 1 and the argument n. The algorithm then
allows the user to guess the number.

Number RandInt(100)
TotalTry 1
REPEAT
PRINT "Enter your guess now, it must be a whole number"
INPUT Guess
IF TotalTry > Number
THEN
PRINT "Too large try again"
ENDIF
IF Guess > Number
THEN
PRINT "Too small try again"
ENDIF
TotalTry Guess + 1
UNTIL Guess <>> Number
TotalTry TotalTry
Tot
talTry - 1
PRINT "Number
"Numbeer of
of guesses ", TotalTry

Find the fourr errors in


n the
the pseudocode
pseu
udocode and suggest
sugg
gest a correction to remove each error.

Error 1 ...............................................................................................................................................
...................
..........................
. ...........
....................
.. . ...............
.......
.........
.....
. ...............................
. ....
. ......
. ......
................

Correcti
ion
on ..
Correction .............................................................................................................................................
.........................................................................................................................................

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

Error 2 ......................................
..........................................................................................................
..............................................................................................................................................

Correction ...................................
........................................................................................................
.........................................................................................................................................

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

Error 3 ..............................................................................................................................................

Correction .........................................................................................................................................

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

Error 4 ..............................................................................................................................................

Correction .........................................................................................................................................

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

© UCLES 2019 2210/22/O/N/19 [Turn over


3$*(

3 (a) The flowchart checks the lengths of a batch of 10 ropes. For the batch to be accepted 90% of
the lengths need to be between 24.9 and 25.1 metres.

START

Reject 0
Count 0

Yes
Is Count =
10 ?
No
No
Count Count + 1 Is Reject
<= 1 ?
INPUT Length
Yes
OUTPUT "Batch
rejected"

Yes Is Length
Lengt
g h <
gt
25.1
5.1 AND
25 AND
Lengthh > 24.9
th 24.9?
4.9

No

Reject Reject + 1

OUTPUT "Batch
accepted"

END

© UCLES 2019 2210/22/O/N/19


3$*(

Complete the trace table for the input data:

24.88, 25.01, 24.98, 25.00, 25.05, 24.99, 24.97, 25.04, 25.19, 25.07

Reject Count Length OUTPUT

[4]

(b) (i) It h
has been
as been
ee n decided to
ooonly
nly reject batches of rope that contain ropes that are too short.

Sttat
ate
Statee the
the change
cha
change required
requ
uired to the algorithm.

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

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

(ii) algorith
th
hm to reject batches could be improved to make it more effective.
Explain how the algorithm

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

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

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

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

© UCLES 2019 2210/22/O/N/19 [Turn over


3$*(

10

4 Fourr validation checks and fourr descriptions are shown.

Draw a line to connect each validation check to the correct description.

Validation Check Description

Range check Checks that some data is entered.

Checks for a maximum number of characters


Presence check
in the data entered.

Checks that the characters entered are all


Length check
numbers.

Checks that the value entered is between an


Type check
upper value and a lower value.
[3]

5 A programmer writes a program


prog
pr og
gram
m to weigh baskets of fruit in grams, keeping a total of the weight
and counting the number
num
mbe er of
of baskets.
baske
kets.. The
ke Th total
tota
al weight
we
eig
ght iss stored
stor
sto ed in
n a variable
va
ari
riab
a le
e Tot la
Tota
Total nd tthe
and he number
number
of baskets
s iis
s st
stor
ored
ored
storedd in
n a vvariable
ariable
e BasketCount.
Bask
sket
sk et
tCo ounnt.

Explain, including
inc
ncludi
ludi
dinng examples
ng examples
xa programming statements, how totalling and counting could be used
of programming
in this program.
prog
prog
ogra
graam.

To
ota
tallling
Totallingg ..
.........
....
.........
.................................................................................................................................
.............................................................................................................................................

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

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

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

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

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

Counting ...........................................................................................................................................

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

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

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

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

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

© UCLES 2019 2210/22/O/N/19


3$*(

10

5 The algorithm performs an operation on the array named MyData

DIV means integer division, so only the whole number part of the result is returned
e.g. 7 DIV 2 returns a value of 3

First 0
Last 16
Found FALSE
INPUT UserIn
WHILE (First <= Last) AND (Found = FALSE) DO
Middle (First + Last) DIV 2
IF MyData[Middle] = UserIn
THEN
Found TRUE
ELSE
IF UserIn < MyData[Middle]
THEN
Last Middle - 1
ELSE
First Middle + 1
ENDIF
ENDIF
ENDWHILE
OUTPUT Found

This table
ble sshows
tab
ab h ws
ho ws tthe
he ccontents
ontents of
of the
eaarray:
rray:
rra a a e.g.
ay: MyData
MyDat
yDat e.g. MyD
yDat
ata[
at 2] stores
g. MyData[2]
a[2] oress tthe
stor he vvalue
a ue 5
al

MyData
Index [0]
[0] [1]
[1] [2]
[1 [2] [3]
[3] [4] [5]
5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16]
[5
Value 2 3 5 6 8 10 0 12
12 13 14 16 18 20 25 27 29 34 36

(a) Complete the trace table for


o the input data: 10
or

First Last UserIn Middle Found OUTPUT

[6]

(b) Describe the function being performed by the algorithm.

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

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

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

............................................................................................................................................. [2]
© UCLES 2019 2210/23/O/N/19
3$*(

11

6 Draw fourr different flowchart symbols and describe how they are used in a program flowchart.

Flowchart symbol Description of use

[4]

© UCLES 2019 2210/23/O/N/19 [Turn over


3$*(

Section B

2 Tick (9) one box in each row to identify if the statement about structure diagrams is true or false.

True False
Statement
(9) (9)
A structure diagram is a piece of code that is available throughout the
structure of a program.
A structure diagram shows the hierarchy of a system.

A structure diagram is another name for an array.

A structure diagram shows the relationship between different components


of a system.
[2]

3 Programs can perform validation and verification checks when data is entered.

(a) Give the names of two different


difffe
erent validation checks and state the purpose of each one.

Check 1 .................
......
.... .............
.........................................................................................................
.....................................................................................................................................

Purp
rpos
rp osse ....
Purpose ....
....
. ........................
.............
........
. ....
..............
.........................
.............................
. ...................................
.....................................................................................................................................

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

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

Ch
hecck 2 .............................
Check ..........................................................................................................
.....................................................................................................................................

Purpose ..............................
........................................................................................................
.....................................................................................................................................

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

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

(b) Give the name of one verification check.

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

(c) Describe the difference between validation and verification.

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

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

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

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

© UCLES 2020 2210/21/M/J/20


3$*(

4 The pseudocode algorithm shown should allow numbers to be entered and should allow
50 numbers to be stored in an array.

Count 0 ĸ
REPEAT
INPUT Values[Count]
Count Count + 1 ĸ
UNTIL Count = 0

(a) Explain why the algorithm will never end.

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

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

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

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

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

(b) Re-write the original pseudocode


pseudo
d code so that it terminates correctly and also prevents numbers
do
sto
tore
tore
below 100 from being storeded in the array Values[ ]

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

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

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

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

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

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

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

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

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

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

(c) Describe how you could change your pseudocode in part (b) so that it prevents numbers
below 100 and above 200 from being stored in the array Values[ ]

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

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

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

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

© UCLES 2020 2210/21/M/J/20 [Turn over


3$*(

10

5 The flowchart represents an algorithm.

The predefined function DIV gives the value of the result of integer division,
for example, y ĸ 9 DIV 4 gives y a value of 2

An input value of –1 ends the algorithm.

START

INPUT
Value

IS Yes
Value =
-1 ?

No

Calc1
Calc
lc1 Value DIV 2

Calc2
Calc
lc2
lc Value DIV 3

IS
No Calc1 =
Value / 2 ?

Yes

IS
No Calc2 =
Value / 3 ?

Yes

OUTPUT
Value
END

© UCLES 2020 2210/21/M/J/20


3$*(

11

(a) Complete the trace table for the input data:

50, 33, 18, 15, 30, –1, 45, 12, 90, 6

Value Calc1 Calc2 OUTPUT

[4]

(b) Describe the purpose


pur
urpo
pose
pose of the
e algorithm.
algo
go
ori
rith
thm.
th

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

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

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

© UCLES 2020 2210/21/M/J/20 [Turn over


3$*(

3 (a) An algorithm has been written in pseudocode to input the names and marks of 35 students.
The algorithm stores the names and marks in two arrays Name[ ] and Mark[ ]. The highest
mark awarded is found and the number of students with that mark is counted. Both of these
values are output.

01 HighestMark 100 ĸ
02 HighestMarkStudents 0 ĸ
03 FOR Count ĸ
1 TO 35
04 OUTPUT "Please enter student name"
05 INPUT Name[Count]
06 OUTPUT "Please enter student mark"
07 INPUT Mark[Counter]
08 IF Mark[Count] = HighestMark
09 THEN
10 HighestMarkStudents HighestMarkStudents – 1 ĸ
11 ENDIF
12 IF Mark[Count] > HighestMark
13 THEN
14 Mark[Count] HighestMark ĸ
15 HighestMarkStudents 1 ĸ
16 ENDIF
17 NEXT Count
18 Hig
i hestMarkStudents," with the highest mark of ",
OUTPUT "There are ", HighestMarkStudents,"
HighestMark

lin
Give linene numbers
numb
num er
mb e s where
where the
the fo
four
urr err
rro
rrors are
errors are to be
be found
f und in
fo n the
the pseudocode.
pse
seudoccod
ode. Suggest
Sug
uggest a
corr
correc
rre tition
ec
correctionon
on for
for each
eac
achh error.

Erro
ro
or 1 lilline
Error ine
n n umbe
um b r ...........
be
number ..........................................................................................................
...................................................................................................................

C orr
rrrec
e ti
tion
Correction n .....
...............................................................................................................................
.................................................................................................................................

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

Error 2 line number .............


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

Correction .................................................................................................................................

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

Error 3 line number ...................................................................................................................

Correction .................................................................................................................................

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

Error 4 line number ...................................................................................................................

Correction .................................................................................................................................

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

© UCLES 2020 2210/22/M/J/20


3$*(

(b) Explain how you could extend the algorithm to also find the lowest mark awarded, count the
number of students with that mark, and output both these values.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

............................................................................................................................................. [6]
© UCLES 2020 2210/22/M/J/20 [Turn over
3$*(

10

4 This flowchart inputs the points won and the points lost when playing a game. The difference
between the points won and lost is calculated and depending on the result the player can: move
up to the next level, stay at the same level, or move down to the previous level. The flowchart
finishes when the input for points won is –1.

START

INPUT
PointsWon, PointsLost

IS
Yes END
PointsWon = –1 ?

No

Difference
PointsWon - PointsLost

OUTPUT
OUTP
OUTPUT
TP T IS
Yes
Ye
es
"Wel
"Well
el
"Welll done
done Difference > =
moove
ve up"
move up" 1000 ?

No

OUTPUT Yes IS
"Sorry move Difference < 0 ?
down"

No

OUTPUT
"Keep on trying"

© UCLES 2020 2210/22/M/J/20


3$*(

11

(a) Complete a trace table for this set of input data:


5000, 4474, 6055, 2000, 7900, 9800, 3000, 2150, –1, 6700, 7615

PointsWon PointsLost Difference OUTPUT

[3]

(b) The flowchart needs to be changed. When the difference is more than 5000 the output
message is ‘Fantastic leap up two levels’.

Describe the changes that will need to be made to the flowchart.


will

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

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

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

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

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

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

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

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

© UCLES 2020 2210/22/M/J/20 [Turn over


3$*(

2 Describe the purpose of validation and verification checks during data entry.

Include an example for each.

Validation check ................................................................................................................................

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

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

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

Verification check ..............................................................................................................................

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

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

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

© UCLES 2020 2210/02/SP/23 [Turn over


3$*(

3 Tick (9) one box to show the named section of a program that performs a specific task.

A file

B function

C parameter

D process
[1]

4 A satellite navigation system is an example of a computer system that is made up of sub-systems.

Part of a satellite navigation system:


x allows the user to enter details for a new destination or select a previously saved destination
x displays directions in the form of a visual map or as a list.

Draw a structure diagram for thi


hiis part of the satellite navigation system.
this

[4]

© UCLES 2020 2210/02/SP/23


3$*(

5 An algorithm has been written in pseudocode to input some numbers. It only outputs any numbers
that are greater than or equal to 100. The number 999 is not output and stops the algorithm.

INPUT Number
WHILE Numbers <> 999 DO
IF Number > 100
THEN
OUTPUT Number
ENDIF
ENDWHILE
OUTPUT Number

(a) Identify the fourr errors in the pseudocode and suggest corrections.

Error 1 .......................................................................................................................................

Correction .................................................................................................................................

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

Error 2 ...............................
.........................................................................................................
.......................................................................................................................................

Correction ....................
.........
.........................................................................................................
.................................................................................................................................

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

Erro
Er ror 3 ........................................................................................................................................
ro
Error ...........
........................................
.. ........................
....................
.. .........
.. ..............
......
. ..
.. .....
...... .............................
.. ................

Cor
rrec
rr ectiion
Correctiono ..
..................................................................................................................................
........
..............................................................................................................................

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

Error 4 ...............................
..........................................................................................................
.......................................................................................................................................

Correction ..........................
........................................................................................................
.................................................................................................................................

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

(b) Write a pseudocode statement to change the corrected algorithm to output all numbers
between 100 and 200 inclusive.

You do not need to rewrite the whole algorithm

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

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

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

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

© UCLES 2020 2210/02/SP/23 [Turn over


3$*(

7 This flowchart represents an algorithm.

START

Flag m 0
Count m 1

IS Name[Count] Yes
> Name[Count + 1]? Temp m Name[Count]

No Name[Count] m Name[Count + 1]

Name[Count + 1] m Temp

Flag
Fl
F lag
g m 1

Count
Co
Couun
nt m Count
t + 1

No IS Count
=4?

Yes

No IS Flag
=0?

Yes

STOP

© UCLES 2020 2210/02/SP/23


3$*(

(a) The array Name[1:4] used in the flowchart contains the following data:

Name[1] Name[2] Name[3] Name[4]


Jamal Amir Eve Tara

Complete the trace table using the data given in the array.

Flag Count Name[1] Name[2] Name[3] Name[4] Temp

Jamal Amir Eve Tara

[5]

(b) Describe what the algorithm represented by the flowchart is doing.

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

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

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

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

© UCLES 2020 2210/02/SP/23 [Turn over


3$*(

&+$37(5

0$5.,1*
6&+(0(
3$*(
3$*(

2210/21 Cambridge O Level – Mark Scheme May/June 2019


PUBLISHED

Question Answer Marks

3(a) Many possible answers, those given are examples only. 2


1 mark per bullet:
 IF
 Condition and outcome

Example answer:
IF X < 0
THEN
PRINT "Negative"
ELSE
PRINT "Not negative"
ENDIF

OR

1 mark per bullet:


 CASE
 Condition and outcome

Example answer:
CASE X OF
1: PRINT ("ONE")
("O
"ONE
NE
E")
2: PRINTNT ("TWO")
("TWO
WO")
WO
OTHERWISE
OTHEERW I E PRINT
RWIS PRINNT ("Less
IN ("
"Le s than
Less an ONE
tha ONE or more
or than
more th n TWO")
TWO
WO")
)
ENDCASE
ENDC
EN DC
D CAS
A E

3(b)  To a
To llow diffe
allow ere
ent routes through a program
different 2
 depe
de pe
endent on
dependent n meeting certain criteria

Question Answer Marks

4(a) Range check 1

4(b) Two from: 2

 The entered number (Value)is being checked to see that it is not


< 0 or not > 100
 If it is, it is rejected and the user has to enter another number / an
error message is displayed
 Otherwise the number is accepted, the word ‘Accepted’ is output
along with the Value

© UCLES 2019 Page 6 of 9


3$*(

2210/21 Cambridge O Level – Mark Scheme May/June 2019


PUBLISHED

Question Answer Marks

4(c) 3
Value OUTPUT

Input a value between 0 and 100


inclusive

200 Invalid value, try again

300 Invalid value, try again

–1 Invalid value, try again

50 Accepted: 50

1 mark – Value column


1 mark – OUTPUT column first line
1 mark – OUTPUT column lines two to five

© UCLES 2019 Page 7 of 9


3$*(

2210/21 Cambridge O Level – Mark Scheme May/June 2019


PUBLISHED

Question Answer Marks

4(d) 5
START

PRINT "Input a
value between
0 and 100
inclusive"

INPUT Value
PRINT "Invalid
value, try
again"

IS Value < 0
Yes
OR
IS Value > 100 ?

No

PRINT
PRI
RINT
RIN
NT
"Ac
Ac
ccep
ceppted
ted: ",
"Accepted:
Value
V
Va
Vallue

END
E ND

1 mark – Input promptt a


and
nd input value
1 mark – Correct decision
decission box labelled sufficiently (Yes/No) – allow 2
decision boxes
1 mark – Remaining outputs
out
u puts correct
1 mark – All connectingg lines and arrows to be complete and correct
1 mark – Standard flowchart symbols used

© UCLES 2019 Page 8 of 9


3$*(

2210/22 Cambridge O Level – Mark Scheme May/June 2019


PUBLISHED

Question Answer Marks

Section B

2(a) 1 mark for each error identified + suggested correction 4


x Low ĸ Count should be Low ĸ Number
x Number > Low should be Number < Low
x UNTIL Count = 99 should be UNTIL Count > 99 or UNTIL
Count = 100 or UNTIL Count >= 100 // Count ĸ 1
should be Count ĸ 0
x PRINT "Largest Number is ", Number should be PRINT
"Largest Number is ", High

2(b) MP1 Add Total ĸ 0 /// Total ĸ Number 4


MP2 Add Total ĸ Total + Number
MP3 Add PRINT "Total is ", Total
MP4 All positioning explained / seen

Count ĸ 1
INPUT Number
High ĸ Number r
Low ĸ Number r
Total ĸ Number
Num
umbe
um b r
be
REPEAT
IN
NPU
PUT Number
INPUT Numb ber
Total
To
ota l ĸ Total
tal otal + Number
Tot
ot Num
mbe
ber
IF
IF Number
Number > High
Hi
igh
THEN
T EN
TH
High ĸ Number
High Number
EN
NDI
DIF
ENDIF
IF Number < Low
THEN
Low ĸ Number
Number
ENDIF
Count ĸ Count
Cou unt + 1
UNTIL Count > 99
PRINT "Largest Number is ", High
PRINT "Smallest Number is ", Low
PRINT "Total is ", Total

© UCLES 2019 Page 6 of 9


3$*(

2210/22 Cambridge O Level – Mark Scheme May/June 2019


PUBLISHED

Question Answer Marks

3 4
Total Count Distinction Mark OUTPUT

0 0 0 50

50 1 0 70

120 2 0 65

185 3 0 30

215 4 0 95

310 5 1 50

360 6 1 55

415 7 1 85

500 8 2 65

565 9 2 35

600 10
1 0 –1 Number of
Dist
Di stiincctio
Distinctionsonss 2

Average Mark 60
1 mamark
ark ffor
o T
or Total
otal and CCount
ount columns both correct.
1 mamarkrk for
for each
each correct
correcct column apart from Total and Count.
If n o ma
no markr s awarded allow
rk
marks allow 1 mark for initialisation of Total, Count and
D
Di ist
sti
tinction, set to zero.
Distinction, zeroo.

© UCLES 2019 Page 7 of 9


3$*(

2210/22 Cambridge O Level – Mark Scheme May/June 2019


PUBLISHED

Question Answer Marks

4 4
Statements Selection Repetition

FOR A ĸ 1 TO 100
B ĸ B + 1 9
NEXT A

CASE A OF
100: B ĸ A
9
200: C ĸ A
ENDCASE

IF A > 100
THEN
9
B ĸ A
ENDIF

REPEAT
A ĸ B * 10 9
UNTIL A > 100

1 mark for each co


corr
correct
rrec
rr ecct row

Question Answer
Answ
An wer Marks
Marks

5 Validation
V
Vaaliidatitiion
on 6
Two
Tw o from:
fro
fr om
om:
x a automated
u omated checking
ut che
hecking
he
x cchecking
hecking thatt data
data is reasonable / of a certain type
x checking thatt data data meets certain criteria

Example 1 mark
x range check //
// length check // type check // check digit etc.

Verification
Two from:
x checking that data has not changed«
x « during input to a computer
x « during transfer between computers / devices

Example 1 mark
x double entry // checking against original // visual check // use of
checksum etc.

© UCLES 2019 Page 8 of 9


3$*(

2210/22 Cambridge O Level – Mark Scheme October/November


PUBLISHED 2019

Section B

Questio Answer Mark


n s

2 One mark for each error identified and suggested correction: 4


x IF TotalTry > Number should be IF Guess > Number
x IF Guess > Number should be IF Guess < Number
x TotalTry ĸ Guess + 1 should be TotalTry ĸ TotalTry + 1
x UNTIL Guess <> Number should be UNTIL Guess = Number

Questio Answer Mark


n s

3(a) Reject Count Length 4


OUTPUT

0 0

0 1 24.88

1 2 25.01

1 3 2
24
24.98
.98
8

1 4 2
25.0
25.00
5.0
00

1 5 25.05

1 6 24.99

1 7 24.97

1 8 25.04

1 9 25.19

2 10 25.07 Batch rejected

One mark for each correct column max. 4

3(b)(i) x Remove Length < 25.1 AND 1

3(b)(ii) Two from: 2


x Check the reject counter after each incrementation/remove reject check
after counter = 10 «
x « as soon as Reject = 2 / >1 ...
x « reject batch and end

© UCLES 2019 Page 5 of 7


3$*(

2210/22 Cambridge O Level – Mark Scheme October/November


PUBLISHED 2019

Questio Answer Mark


n s

4 3

One mark for each correct line, up to maximum of three marks.

Questio Answer Mark


n s

5 Totalling:
Tota
To t lllin
ta ing:
g: 4
x A Adding
d in
dd the
ng th off ea
he weight o each basket
ach b asske o tthe
et to total
he tot
ota
ot al w
al weight
eiigh each
ht as e ach
ac weight
h we
weig
ight
ht iss
entered
ente
en tere
red
re d
x To Total
T tal = Total + Weight
tal

Counting:
C
Co unti
un ting
ti ng::
ng
x A Adding
dding one to/incre
to/incrementing
ementing the number of baskets as each weight is
entered
x BasketCount = BasketCount
BasketCount + 1

© UCLES 2019 Page 6 of 7


3$*(

2210/23 Cambridge O Level – Mark Scheme October/November


PUBLISHED 2019

Question Answer Marks

2 Two from 2
 Sub-program / system not the whole program / system
 To perform a frequently used operation within a program
 That can be called when needed
 That can be reused by another program

Question Answer Marks

3  FOR (… TO … NEXT)loop 3
 WHILE (… DO … ENDWHILE) loop
 REPEAT (… UNTIL) loop

Question Answer Marks

4(a)  Conditional / selection statement 1

4(b) Four from: 4


MP1 CASE statementt with with identifier Response
struct
MP2 Correct structurectur
ct u e used
ur used for choices«
MP3 «. correc ct st
correct stat
atemments used for choices
statements
OTHE
MP4 OTHERWISEERWWISSE an nd co
and orr
rrec
ect stat
correct atemen
entt
statement
MPP5 Si
MP5 Sing
ng
gle
eE
Single NDCASE
ND
ENDCASE E inc
clu
lude
ded
de
included
e.g
e. g.
e.g.
CA
ASE
CASESE OF
OF Response
R sponse //
Re // CASE Response OF
1 : X ĸ X + Y
2 : X ĸ X - Y
3 : X ĸ X * Y
4 : X ĸ X / Y
OUTPU
OTHERWISE OUTPUT UT ƎNo responseƎ
ENDCASE

Question Answer Marks

5(a) First Last UserIn Middle Found 6


OUTPUT

0 16 FALSE

0 16 10 8 FALSE

0 7 10 3 FALSE

4 7 10 5 TRUE TRUE

One mark per correct column

© UCLES 2019 Page 6 of 8


3$*(

2210/23 Cambridge O Level – Mark Scheme October/November


PUBLISHED 2019

Question Answer Marks

5(b) Two from: 2


 Search for the value input «
 « using an array«
 « of sorted data

Question Answer Marks

6 One mark for each correct symbol and name / description / example of use 4
(maximum four marks)

Symbol Description of use

Terminator – start / end the


flowchart

Process – to show calculations,


etc.

Input / Output

Decision – to show condition

Continuation – to extend the


flowchart and allow it to join up

© UCLES 2019 Page 7 of 8


2210/21 Cambridge O Level – Mark Scheme May/June 2020
PUBLISHED
Question Answer Marks

1(c) OUTPUT "Your code doesn’t exist, please


ple
l ase try again"
ENDIF
ENDWHILE
IF DeviceType ← "Phone"
THEN
OUTPUT "Would you like a SIM Card?
Card?
? (Answer
(An
Answ
sw
wer
r Y or
or N)"
INPUT SimRequired
ENDIF

1(d) Any five from 5


• Explanation of finding if more than one device is purchased
dev
evvic
ice
• Explanation of application of device e discount
disc
di scou
sc ount
ou nt
• Explanation of calculating the discount(s) and finding the new price
• Explanation of outputting new total
• Explanation of outputting amount saved
• Explanation of messages used
3$*(

Question Answer
An swer
wer Marks

2 2
True False
Statement
(9) (9)

A structure diagram is a piece of code that is available tthroughout


hrou
rou
o ghout the structure of a program. 9

A structure diagram shows the hierarchy of a system. 9

A structure diagram is another name for an array. 9

A structure diagram shows the relationship between different


differe
rent
nt ccomponents
o ponents of a system.
om 9

Two marks for four correct rows.


One mark for three correct rows.

© UCLES 2020 Page 6 of 10


2210/21 Cambridge O Level – Mark Scheme May/June 2020
PUBLISHED
Question Answer Marks

3(a) One mark for each correct validation check (max two)) 4
• Range
• Length
• Type
• Check Digit

e.g.
One mark for each correct related purpose (max two)) e.
e g.
spec
pecciffic
• To make sure the data entered falls within a specific i set
et of
of values
valu
va l es
specified
• To make sure the data entered is no longer than specifi ed
d
whether
• To make sure the data entered follows rules related to whethe herr it iis
he s numbers of letters
• To make sure an identification code entered is ge g
genuine
nuine or possible
possiblele

3(b) One mark for correct verification check (max one) 1


• Double (data) entry
• Visual check

3(c) Any two correct statements (max two) e.g. 2


cann
not
o check
• Validation checks if the data entered is possible/it cannot che
h ck if data has been entered correctly.
3$*(

• Verification checks if the data entered matches the data submitted


a su
subm
b itted for entry/ it does not check if data matches set
criteria.

Question Answer
An swer
wer Marks

4(a) Any two correct statements (max two) e.g. 2


• The value of the variable Count begins as 0 …
op ccondition
• … and is incremented by 1 before it is tested by the loop ondition
on
• Count will never be 0 at the end of the loop

© UCLES 2020 Page 7 of 10


2210/21 Cambridge O Level – Mark Scheme May/June 2020
PUBLISHED
Question Answer Marks

4(b) 4
Count ĸ 0
REPEAT
INPUT Number
IF Number >= 100
THEN
Values[Count] ĸ Number
ENDIF
Count ĸ Count + 1
UNTIL Count = 50

One mark – separate INPUT statement


One mark – IF statement attempted
One mark – IF statement completely correct
One mark – termination of loop updated

4(c) Any two correct statements (max two) e.g. 2


statement/comparison
• Alter the IFstatement/add a second IF statement/compa arison that’s already there …
<=200
0
• … so that additional criteria set an upper limit of <=200
3$*(

© UCLES 2020 Page 8 of 10


2210/21 Cambridge O Level – Mark Scheme May/June 2020
PUBLISHED
Question Answer Marks

5(a) 4
Value C lc1
Ca
Calc1 Calc2 OUTPUT

50 25
25 16

33 16
16 11

18 9 6 18

15 7 5

30 15 10 30

-1
3$*(

One mark for each correct column (max four)

5(b) Any two correct statements e.g. 2


• The program outputs a value
• That is divisible by 6 // 2 and 3

© UCLES 2020 Page 9 of 10


2210/22 Cambridge O Level – Mark Scheme May/June 2020
PUBLISHED
Section B

Question Answer Marks

2 Real 5
Integer
Char/String
String
Boolean

Question Answer Marks

3(a) One mark for error and correction 4


Line 1 HighestMark ← 0
Line 7 INPUT Mark[Count]
HighestMarkStudents
Line 10 HighestMarkStudents ← HighestMarkStudents s + 1
Line 14 HighestMark ← Mark[Count]

3(b) Any six from: 6


3$*(

Add variable LowestMark …


… Set this to a high value for example 100
Add variable LowestMarkStudents …
… Set this to zero
Check iff Mark[Count] = LowestMark …
… True – add 1 to LowestMarkStudents
Check iff Mark[Count] < LowestMark …
LowestMark
Mark
… True – set LowestMarkStudenta to 1 and set LowestMa rk to Mark[Count]
Add extra output statement

© UCLES 2020 Page 6 of 8


2210/22 Cambridge O Level – Mark Scheme May/June 2020
PUBLISHED
Question Answer Marks

4(a) PointsLo
Lost)
Lo
One mark for correct input (PointsWon and PointsLost) 3
One mark for correct calculations (Difference)
One mark for correct output

PointsWon PointsLost
s
st Difference
Dif
i fe
f re
rence OUTPUT

5000 4474 5
52
5266 Keep on trying

6055 2000 4055 Well


Well done move up

7900 9800
9800 -1900
-190
-1
190
900
0 Sorry
Sorr
So rryy move
rr m ve down
mo

3000 2150 850


850 Keep on trying

-1 6700
3$*(

4(b) Any three from: 3


• Add extra decision box …
100
0 0
• … before checking for difference greater than or equal to 1000
// change Is difference >= 1000 to >= 1000 and <= 5000
00
0
• Check for difference greater than 5000
• Add extra Output ‘Fantastic leap up two levels’…
• … before flowline returns to input

© UCLES 2020 Page 7 of 8


2210/02 Cambridge O Level – Mark Scheme For examination
SPECIMEN from 2023

Question Answer Marks


1(b) x appropriate loop controls 3
x read from array
x output from array (the last two points can be in one
one tate
tat ment
ent
n , see example)
n sstatement,

sam
ame
am
Note: reading and the output MUST be within the same lo
oop
o .
e loop.

For example:
Count m 0
WHILE Count < 50 DO
OUTPUT Name[Count]
Count m Count + 1
ENDWHILE

Question An swer
wer
e
Answer Marks
2 Validation check 4

One mark for description:


x e sible.
en
To test if the data entered is possible / reasonable / ssensible.
3$*(

x spec
A range check tests that data entered fits within specified valu
lues
ues
e .
eccifified values.

One mark for example:


x Allow any correct validation check as an example (ra
ra
ang
n e, len
(range, ngth
gtth, type, presence, format, etc.).
length,

Verification check

One mark for description:


x To test if the data input is the same as the data that wa inten
as
was nde
ded
intended d to be input.
x A double entry check expects each item of data to be b entered w ce
wi c and compares both entries to check they are the
d ttwice
same.

One mark for example:


a , double
al
Allow any correct verification check as an example (visual
(visual, ee ntry
nt
tr , etc.).
entry,

© UCLES 2020 Page 5 of 16


2210/02 Cambridge O Level – Mark Scheme For examination
SPECIMEN from 2023

Question Answer Marks


3 B 1

Question Answer
An sw
weerr Marks
4 One mark for a hierarchical structure. 4
One mark for suitable names for the sub-systems.
One mark for identifiable inputs.
One mark for identifiable outputs.

For example:

Satellite
Sate
tellllititite
enna
navigation
avi
viga
gatit on
on ssystem
yysste
t m

Input destination Output directions


3$*(

New destination Saved destination Map


M
Ma p List

Question Answer
Answ
wer
e Marks
5(a) One mark for each error identified and correction: 4
x Numbers should be Number
x IF Number > 100 should be IF Number >= 100 00 0
x INPUT Number is missing from inside the loop, inse ert INPUT
insert Nu
umb
T Number
m er after the ENDIF statement.
x The final OUTPUT Number is not needed, remove it. t
t.
5(b) inequality
One mark for both ends of the range and correct inequ allitity symbols.
ty symbol
o s. 2
One mark for the AND // nested IFs.
The test should be IF Number >= 100 AND Number <= < 200200
0

© UCLES 2020 Page 6 of 16


2210/02 Cambridge O Level – Mark Scheme For examination
SPECIMEN from 2023

Question Answer Marks


7(a) Flag Count Name[1] Name[2] Name[
Name[3]
e[
[3]
3 Name[4] Temp 5

Jamal Amir Eve Tara


T ra
Tar
0 1 Amir Jamal
Jama l Eve
Eve
e Tara
Tara
Tara Jamal
1 2 Amir Eve Jamal
Jam
amal
amal
l Tara
Tara
ra Jamal
1 3 Amir Eve Jamal
J amal
mal
a Tara
T ra
Tara Jamal
1 4 Amir Eve Jamal
Jamal
l Tara
T ra
Ta Jamal
0 1 Amir Eve Jamal Tara
Tara
a Jamal
0 2 Amir Eve Jamal Tara Jamal
J mal
Ja
0 3 Amir Eve
Ev
ve Jamal
Jam
amal
al Tara
Tar
Tara
a Jamal
Jama
Jam l
0 4 Amir Eve Jamal
l Tara
Ta
ara Jamal

One mark for Flag column.


One mark for Count column.
One mark for Temp column.
Two marks for all correct Name columns or one mark forr tw three
two or thr
hree
hr ee ccorrect
orrect Name columns.
3$*(

Note: Repeated values do not need to be written unless a value iss rrewritten.
ewritten.
ew
w
7(b) x bubble sort / sorting the names 2
x eti
ascending order / A to Z / lowest to highest / alphabe tical orde
alphabetical de
er
order

Question Answer
An swer
wer Marks
8 One mark for each. 3

10.00௕ERXQGDU\DEQRUPDOGDWDWKHSULFHVKRXOGEHUH
0
10.00௕ERXQGDU\DEQRUPDOGDWDWKHSULFHVKRXOGEHUHMHFWHGYDOXHLVRXWRIUDQJH
UHMH
UH MHFWHGYDO
MH DOXH
X LVRXWRIUDQJH
9.99௕௕ERXQGDU\H[WUHPHQRUPDOGDWDWKH
9.99௕௕ERXQGDU\H[WUHPHQRUPDOGDWDWKHSULFHVKRXOGEHDFFHSWHGYDOXHLVZLWKLQQRUPDOUDQJH
SULFHVKRRXO
X G EHDFF
F HSW
FF S HGYDOXHLVZLWKLQQRUPDOUDQJH
ten௕௕௕DEQRUPDOGDWDLQSXWVKRXOGEHUHMHFWHGYDO
ten௕௕௕DEQRUPDOGDWDLQSXWVKRXOGEHUHMHFWHGYDOXHLVZURQJW\SH
XH
H LV
V ZURQJJ W\S\SHH

© UCLES 2020 Page 8 of 16

You might also like