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 | |
|---|---|---|
| 1DECLARE Name : STRING | AStep 1: declare a variable to hold the data that will be written to or read from the file. | |
| 2CLOSEFILE("Scores.txt") | BOPENFILE "Names.txt" FOR WRITE | |
| 3After declaring variables, open the file in WRITE mode so data can be stored in it | CThe final step: close the file once all the reading or writing is finished so the data is safely saved. | |
| 4A comment explains the purpose of the file, and keywords are in capitals | D// Store the high scores for the quiz game | |
| 5OPENFILE "Names.txt" FOR WRITE DECLARE Name : STRING WRITEFILE "Names.txt", Name CLOSEFILE "Names.txt" | EThe statements are in the wrong order. OPENFILE comes before DECLARE, but the variable should be declared first. | |
| 6DECLARE Name : STRING OPENFILE "Names.txt" FOR WRITE WRITEFILE "Names.txt", Name | FThe program never closes the file. CLOSEFILE "Names.txt" is missing from the end. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
DECLARE, OPENFILE, WRITEFILE, CLOSEFILE — The order of a complete file program: declare variables, open the file in the right mode, read or write the data, then close the file. Keywords are in capitals and statements are indented.DECLARE PlayerName : STRING
OPENFILE "Players.txt" FOR WRITE
WRITEFILE "Players.txt", PlayerNameDECLARE PlayerName : STRING
OPENFILE "Players.txt" FOR WRITE
WRITEFILE "Players.txt", PlayerNameOPENFILE "Players.txt" FOR WRITE
WRITEFILE "Players.txt", PlayerName
CLOSEFILE "Players.txt"OPENFILE "Players.txt" FOR READ
READFILE "Players.txt", PlayerName
CLOSEFILE "Players.txt"DECLARE Score : INTEGER
OPENFILE "Score.txt" FOR WRITE
WRITEFILE "Score.txt", Score