Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1CLOSEFILE "Scores.txt" | ACloses the file named Scores.txt when the program has finished with it, so the data is saved and the file is released. | |
| 2OPENFILE "Scores.txt" FOR WRITE WRITEFILE "Scores.txt", Score CLOSEFILE "Scores.txt" | BCLOSEFILE is placed before the READFILE, so the file is closed before the data is read. It should come after the last read. | |
| 3The identifier in CLOSEFILE must match the identifier used in OPENFILE | CThe file is closed straight after the last write, and the identifier is the same in all three statements. | |
| 4Every file that was opened must be closed, so two opened files need two CLOSEFILE statements | DOPENFILE "In.txt" FOR READ OPENFILE "Out.txt" FOR WRITE CLOSEFILE "In.txt" CLOSEFILE "Out.txt" | |
| 5OPENFILE "Scores.txt" FOR WRITE WRITEFILE "Scores.txt", Score CLOSEFILE "Score.txt" | EOPENFILE "Names.txt" FOR READ READFILE "Names.txt", Name CLOSEFILE "Names.txt" | |
| 6OPENFILE "Scores.txt" FOR READ CLOSEFILE "Scores.txt" READFILE "Scores.txt", Score | FThe identifier in CLOSEFILE ("Score.txt") does not match the one in OPENFILE ("Scores.txt"), so the opened file is never closed. It should be CLOSEFILE "Scores.txt". |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
CLOSEFILE "Scores.txt" — Closes the file named in the identifier once you have finished reading or writing, so data is saved and the file is released. The name must match the one used in OPENFILE.OPENFILE "Scores.txt" FOR WRITE
WRITEFILE "Scores.txt", Score
CLOSEFILE "Scores.txt"OPENFILE "Scores.txt" FOR WRITE
WRITEFILE "Scores.txt", Score
CLOSEFILE "Scores.txt"OPENFILE "Names.txt" FOR READ
READFILE "Names.txt", Name
CLOSEFILE "Names.txt"OPENFILE "Names.txt" FOR READ
READFILE "Names.txt", Name
CLOSEFILE "Names.txt"READFILE "Scores.txt", Mark
OUTPUT Mark
CLOSEFILE "Scores.txt"