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 | |
|---|---|---|
| 1OPENFILE "scores.txt" FOR WRITE READFILE "scores.txt", Score | AThe file identifier in READFILE (mark.txt) is different from the one in OPENFILE (marks.txt), so the file names do not match | |
| 2OPENFILE "names.txt" FOR WRITE WRITEFILE "names.txt", Name | BError: READFILE is used on a file opened for WRITE, so the program cannot read from it | |
| 3Every file must be opened with OPENFILE before READFILE or WRITEFILE can use it | CCLOSEFILE is missing, so the file is never closed and the data may not be saved properly | |
| 4A file should be closed with CLOSEFILE once the program has finished using it | DOPENFILE "data.txt" FOR READ READFILE "data.txt", Item | |
| 5OPENFILE "marks.txt" FOR READ READFILE "mark.txt", Mark | EWRITEFILE "log.txt", Line CLOSEFILE "log.txt" | |
| 6OPENFILE "diary.txt" FOR WRITE WRITEFILE "diary.txt", Entry // program ends | FError: the file is opened FOR WRITE, which wipes any old data in names.txt before the new data is saved |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
file handling error — A mistake such as using the wrong mode, missing OPENFILE or CLOSEFILE, using different file names, or opening a file FOR WRITE and wiping its old data.OPENFILE "names.txt" FOR READ
READFILE "names.txt", Name
CLOSEFILE "names.txt"OPENFILE "scores.txt" FOR READ
READFILE "scores.txt", Score
CLOSEFILE "scores.txt"OPENFILE "log.txt" FOR WRITE
WRITEFILE "log.txt", Message
CLOSEFILE "log.txt"OPENFILE "marks.txt" FOR READ
READFILE "marks.txt", Mark
CLOSEFILE "marks.txt"// Old data is lost after this line
OPENFILE "best.txt" FOR WRITE
WRITEFILE "best.txt", NewScore