Past-paper question · 2015 May-June · Paper 21 · Q3(c)(iii)

Question 3(c)(iii) 2015 · May-June · Paper 21 · 5 marks

Question 3

Part (c)

(iii)

Question 3

A board game is designed for two players, O and X.

At the beginning, all cells of a 3 x 3 grid are empty.

The players take turns in placing their marker in an empty cell of the grid; player O always starts.

The game ends when one player completes a row, column or diagonal or the grid is full.

Here is one example after three turns:

O

O X

Ali wants to write a program to play the game. Ali uses the top-down design approach for his overall program solution.

His design is as follows:

01 GameEnd ← FALSE 02 CurrentPlayer ← 'O' 03 CALL DisplayGrid() 04 05 REPEAT 06 CALL PlayerTakesTurn(CurrentPlayer) 07 CALL DisplayGrid() 08 IF HasPlayerWon() = TRUE 09 THEN 10 GameEnd ← TRUE 11 OUTPUT "Player", CurrentPlayer, "has won" 12 ELSE 13 IF GridFull() = TRUE 14 THEN 15 GameEnd ← TRUE 16 OUTPUT "Draw" 17 ELSE 18 CALL SwapPlayer(CurrentPlayer) 19 ENDIF 20 ENDIF 21 UNTIL GameEnd = TRUE

(iii)

Give the line number of a statement which shows:

Assignment .......................................................................................................................

Selection ...........................................................................................................................

Iteration .............................................................................................................................

a Function call ...................................................................................................................

a Procedure call ................................................................................................................

[5]

Question 9

Reveal official mark-scheme answer Official mark-scheme answer for 3(C)(III)

Official answer for Question 3

Part (c)

(iii)

(iii)

Displacement ASCII(MostFrequentLetter) – ASCII('E')

[1]

Mark scheme 9691_s15_ms_21.pdf →

Topic relevance

Why this question appears here

99% 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_s15_qp_21.pdf

Keep practising this topic