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 | |
|---|---|---|
| 1WRITEFILE "Scores.txt", 45 | AOUTPUT Total | |
| 2READFILE "Scores.txt", Num | BAdds the value 45 as the next item in the file, so the trace table's file column gains a new entry. | |
| 3Reopening a file for WRITE erases the old data, so the trace table shows the file as empty before the new writes. | CThe first READFILE reads the first unread item, so X should be 5, not 8. | |
| 4The final OUTPUT is found by reading the last value recorded in the variable column of the trace table. | DCopies the next unread item from the file into Num, so the trace table shows Num's new value. | |
| 5File after WRITEFILE "A.txt", 5 then 8: only 8 | EThe trace forgot that each WRITEFILE adds an item. After both commands the file holds 5 and 8, not just 8. | |
| 6READFILE "A.txt", X traced as X = 8 (file holds 5, 8) | FOPENFILE "Log.txt" FOR WRITE |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
trace table — A table that follows a program step by step, recording the file contents and each variable's value after every file command, until you find the final OUTPUT.OPENFILE "N.txt" FOR WRITE
// N.txt is now empty: old data erased
WRITEFILE "N.txt", "Zoe"WRITEFILE "N.txt", Name
// File now holds the value of Name
CLOSEFILE "N.txt"DECLARE Name : STRING
READFILE "N.txt", Name
OUTPUT NameREADFILE "N.txt", Name
READFILE "N.txt", Name
OUTPUT NameCLOSEFILE "N.txt"
OPENFILE "N.txt" FOR READ
READFILE "N.txt", Name