Paper 2 (9618/21) Oct/Nov 2024

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/12

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

13 Terms

1
New cards

Which keyword replaces a final CASE condition to catch anything unmatched?

OTHERWISE

2
New cards

What are the general steps to output the last 3 lines of a file, in order?

  • Open file for reading

  • Loop until end of file

  • Read line into a temporary variable

  • Shift previous values: LineX ← LineY, LineY ← LineZ

  • Assign new line: LineZ ← ThisLine

  • Close file

  • Output LineX, LineY, LineZ

3
New cards

Why are the variables shifted (LineX ← LineY, etc.) when reading a file?

To ensure that only the last three lines are stored, in the correct order for final output.

4
New cards

How can you modify a file-reading algorithm to output 3 lines starting from a specific line number?

  • Loop until you reach the starting line (check for EOF and return FALSE if reached early)

  • Then read 3 lines (again, return FALSE if EOF is reached too soon)

  • Output each line

  • Return TRUE if successful

5
New cards

What type of error occurs when a program runs but crashes due to bad input? Give a cause.

  • Type: Run-time error

  • Cause: Invalid input or action, e.g., division by zero or converting a non-numeric string to a number.

6
New cards

Give one reason to use a module for repeated logic and state what this avoids.

  • Reason: Makes the program easier to test, debug, and maintain — change logic in one place only.

  • Avoided: Code duplication and inconsistent logic across the program.

7
New cards

Match these activities to their life cycle stages:

Activity

Life Cycle Stage

Interview client about system

Write code

Define records/files

Use walkthrough method

Modify for new hardware

Activity

Life Cycle Stage

Interview client about system

Analysis

Write code

Coding

Define records/files

Design

Use walkthrough method

Testing

Modify for new hardware

Maintenance

8
New cards

What type of testing is done on individual modules before combining them?

  • Integration testing (when combining modules)

  • Unit testing (if testing a single function on its own before integration)

(Note: Mark scheme said “integration,” but if the function is tested before combining, it’s “unit.”)

9
New cards

Give two advantages of using arrays instead of multiple selection statements.

  1. Fewer lines of code — cleaner, shorter logic.

  2. Easier to modify or maintain — values are stored in a single location and can be accessed using indexes.

10
New cards

What are the key components to include when drawing a structure chart for a program with subroutines?

  • Show all modules in the correct hierarchy (e.g., top-down: main procedure → subroutines)

  • Include parameters for each call (use arrows or labels)

  • Show return values from functions

  • Use curved arrow to represent repetition or recursion

  • Connect modules using single lines (not multiple arrows)

11
New cards

If a file needs to be updated by adding data (not overwritten), what must change?

Open the file in APPEND mode instead of WRITE mode

12
New cards

What is a local variable?

  • A variable declared inside a subroutine

  • Can only be accessed and used within that subroutine

13
New cards

Give one reason to use local variables in subroutines.

  • Prevents conflicts with variables in other parts of the program

  • Makes subroutines more modular, self-contained, and easier to debug