Question 4(b)(iii) 2012 · May-June · Paper 23 · 15 marks
Reveal official mark-scheme answer
The answer for this question is in the official mark scheme: open the mark scheme.
Show text version of question
Question 4
Part (b)
(iii)
Question 4
Question 6
2 Gina is developing her programming skills in string handling. For She is going to input one string. Examiner's Use The string contains letters and zero or more '*' characters in any positions. Gina wants to remove all the '*'s and output the letters in their original order. For example:
- input “com*put**er*”, the output is “computer”
- input “hardware”, the output is “hardware”
She writes this code as the function ChangeString because it will be used several For times. Examiner's Use
(iii)
State why Gina uses a function rather than a procedure.
Question 8
3 Liliane wants to write a program to play chess. She will represent the board of 8 x 8 For squares, using the 2-dimensional array Board[8,8]. Examiner's Use Each element of the array will need initialising to zero. Later, if a chess piece is on a square, it will take a value of 1. She starts by writing pseudocode for the initialisation of a 4 x 4 board. This is easier to trace.
01 RowNo ← 1 02 WHILE RowNo < 4 DO 03 ColumnNo ← 1 04 WHILE ColumnNo < 4 DO 05 Board[RowNo,ColumnNo] ← 0 06 ColumnNo ← ColumnNo + 1 07 ENDWHILE 08 RowNo ← RowNo + 1 09 ENDWHILE
Part (a)
To test this pseudocode she traces it until the first five elements of Board have been
initialised.
Complete the headings and the trace for these first five elements of the array.
Board RowNo ColumnNo RowNo<4 ColumnNo<4 [1,1] 1 1 True True 0
Question 9
Part (b)
There is an error in the pseudocode. For
Examiner's Use State the type of error.
Why this question appears here
82% assigned-topic match · Programming › Constructs
Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.
Permanent source page: Educate A Change · From 9691_s12_qp_23.pdf
