Files (Cambridge (CIE) A Level Computer Science): Flashcards

Exam code: 9618

1/20

0Still learning

Know0

  • Define file handling.

Cards in this collection (20)

  • Define file handling.

    File handling is the use of programming techniques to work with information stored in text files.

  • Name the four main file handling techniques.

    Opening, reading, writing and closing text files.

  • Write the pseudocode to open a file called fruit.txt for reading.

    OPENFILE "fruit.txt" FOR READ

  • Write the pseudocode to open a file called Shopping.txt for writing.

    OPENFILE "Shopping.txt" FOR WRITE

  • Write the pseudocode to close a file called fruit.txt.

    CLOSEFILE "fruit.txt"

  • Write the pseudocode to read a line from fruit.txt into FruitName.

    READFILE "fruit.txt", FruitName

  • Write the pseudocode to write the word Oranges to fruit.txt.

    WRITEFILE "fruit.txt", "Oranges"

  • True or False?

    READFILE writes a line to a file.

    False.

    READFILE reads a line from a file. WRITEFILE is the command that writes a line to a file.

  • Write the pseudocode condition that checks the end of fruit.txt has not been reached.

    IF NOT EOF("fruit.txt") THEN

  • The function          returns TRUE when the end of a file has been reached.

    The function EOF returns TRUE when the end of a file has been reached.

  • How do you create a new file in pseudocode?

    Use OPENFILE "Shopping.txt" FOR WRITE, which overwrites the file or creates it if it does not exist.

  • Which mode adds data to the end of an existing file?

    FOR APPEND, written as OPENFILE "Shopping.txt" FOR APPEND.

  • What is the difference between opening a file FOR WRITE and FOR APPEND?

    FOR WRITE overwrites or creates the file, whereas FOR APPEND adds to the end of an existing file.

  • Which loop is used to read every line of a file until the end?

    A WHILE NOT EOF(...) loop, closed with ENDWHILE.

  • True or False?

    A file should be closed before it has been fully read.

    False.

    The file is closed after the reading loop has finished, using CLOSEFILE.

  • In the fruit-counting example, what does FruitCount store?

    An INTEGER that keeps track of how many fruits have been read from the file.

  • In the fruit-counting example, what does FruitFile store?

    A STRING holding the name of the file being read, "fruit.txt".

  • A program reads 25 integers from Data.txt into an array.

    Which two loop options are accepted?

    A WHILE NOT EOF("Data.txt") DO ... ENDWHILE loop, or a FOR Counter ← 1 TO 25 ... NEXT Counter loop.

  • When reading a file into an array, how is each value stored?

    DataArray[Counter] ← LineData, with Counter incremented on each pass of the loop.

  • When reading a file into an array with lower bound 1, Counter is initialised to          before the loop.

    When reading a file into an array with lower bound 1, Counter is initialised to 1 before the loop.

Sign up to unlock flashcards

or