Past-paper question · 2016 May-June · Paper 22 · Q3(e)

Question 3(e) 2016 · May-June · Paper 22 · 5 marks

Original past-paper question for 3(E)
Original past-paper question for 3(E)
Original past-paper question for 3(E)
Original past-paper question for 3(E)
Original past-paper question for 3(E)
Original past-paper question for 3(E)
Reveal official mark-scheme answer Official mark-scheme answer for 3(E)Official mark-scheme answer for 3(E)

Official answer for Question 3

Part (e)

Part (e)

Example VB.NET:

Max[5]

✓
SUB SavePuzzleToFile(Puzzle)
✓
(1)
✓
DIM FileWriter AS StreamWriter
✓
(1)
✓
DIM Row, Column AS INTEGER
✓
(1)
✓
FileWriter = New StreamWriter("Puzzle.TXT")
✓
(1)
✓
FOR Row = 1 TO 11
✓
FOR Column = 1 TO 11
✓
FileWriter.Write(Puzzle(Row, Column))
✓
(1)
✓
NEXT Column
✓
FileWriter.WriteLine()
✓
NEXT Row
✓
(1)
✓
FileWriter.Close()
✓
(1)
✓
END SUB
✓
Example VB6:
✓
Sub SavePuzzleToFile(Puzzle)
✓
Dim i as Integer
✓
Open "Puzzle.TXT" For Output As #1
✓
For i = 1 To 11
✓
For j = 1 TO 11
✓
Write #1, Puzzle(i,j)
✓
Next j
✓
Next i
✓
Close#1
✓
End Sub
✓
Example Python:
✓
def SavePuzzleToFile(Puzzle) :
✓
PuzzleFile = open("Puzzle.TXT", "w")
✓
for i in range(1,12) :
✓
for j in range(1,12):
✓
PuzzleFile.write(str(Puzzle[i][j]))
✓
PuzzleFile.write("\n")
✓
PuzzleFile.close()
✓
Mark Scheme
✓
Syllabus
✓
Paper
✓
Cambridge International AS/A Level – May/June 2016
✓
9691

Question 22

✓
Example Pascal:
✓
PROCEDURE SavePuzzleToFile(Puzzle);
✓
(1)
✓
BEGIN
✓
VAR PuzzleFile : TEXTFILE;
✓
VAR Row, Column : INTEGER;
✓
(1)
✓
ASSIGNFILE (PuzzleFile, 'Puzzle.TXT');
✓
(1)
✓
REWRITE (PuzzleFile);
✓
(1)
✓
FOR Row := 1 TO 11 DO
✓
FOR Column := 1 TO 11 DO
✓
(1)
✓
WRITE(PuzzleFile, Puzzle[Row, Column]);
✓
(1)
✓
CLOSEFILE(PuzzleFile);
✓
(1)
✓
END;
✓
Mark as follows:
  • procedure heading and ending
  • declaration of local variables
  • assigning a file name
  • open file for writing
  • nested loop to access each array element
  • write element out to file
  • close file

Mark scheme 9691_s16_ms_22.pdf →

Show text version of question

Question 3

Part (e)

Question 3

A crossword puzzle is based on a grid made up of white and black squares. The white squares are

to be filled with letters to form words across the grid and down the grid.

The crossword puzzle designer provides clues for each word. Words consist of at least 2 letters.

The square where a word starts, across or down, is numbered. The numbering starts at the top left of the grid and is consecutive, row by row.

Here is an example of a crossword grid:

1 2 3 4 5 6

7 8

9 10 11

12 13 14

Question 15

16 17

18 19

Part (e)

Zara wants to save the contents of the data structure Puzzle to a sequential file

Puzzle.TXT

Write program code for the procedure SavePuzzleToFile(Puzzle).

Programming language ............................................................................................................

Code .........................................................................................................................................

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

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

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

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

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

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

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

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

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

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

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

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

[5]

Question 15

Topic relevance

Why this question appears here

82% assigned-topic match · Data types and structures › Files

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_s16_qp_22.pdf

Keep practising this topic