HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
  1. Notes
  2. /Arrays and Files: Quick Revision
Computer ScienceAlso Python Programming

Arrays and Files: Quick Revision

A brief note on arrays and files in Cambridge pseudocode: one-dimensional and two-dimensional arrays, loops over them, and opening, reading, writing and closing text files, with the usual slips. With practice, a program and questions to check yourself.

StemPy LabWritten by StemPy Lab
Log in to save

A brief note on Arrays and Files. Read it before a test. Try each question at the end before you open its answer.

Arrays

  • 1D: DECLARE Names : ARRAY[1:30] OF STRING. Fixed length, one data type.
  • 2D: DECLARE Board : ARRAY[1:3, 1:3] OF CHAR. The row first, then the column.
  • An element: Names[3], Board[2, 1]. The index may be a variable: Names[i].
  • Bounds: state the lower bound. Pseudocode usually starts at 1; Python lists at 0.
  • Size of a 2D array: rows times columns.

Loops over arrays

  • Fill or read every element: FOR i ← 1 TO 30 ... NEXT i.
  • 2D: nested loops, the outer for the rows, the inner for the columns.
  • Largest or smallest: start with the first element, not with 0.
  • Row totals: set the row total to 0 inside the outer loop, before the inner loop.

Files

  • Why: data in a file is kept after the program stops.
  • OPENFILE "Name.txt" FOR READ or FOR WRITE. WRITE makes a new file; old data is lost.
  • READFILE "Name.txt", Variable reads the next line.
  • WRITEFILE "Name.txt", Value writes a line.
  • CLOSEFILE "Name.txt" when you have finished. One mode at a time.

Practice with new numbers

A program to try

The program saves a 2D list to a file, one row a line, and reads it back.

Read it first. Then run it. Is the table read back the same as the one saved?

1. Add a fourth row to the table. What else must change in the program?

Mistakes to avoid

  • An index outside the bounds, such as Names[31] in ARRAY[1:30].
  • The row and the column swapped in a 2D array.
  • WRITE mode on a file you meant to keep.
  • Reading in a different order from the order written.
  • Forgetting CLOSEFILE.

Check yourself

  1. How many elements does ARRAY[1:6, 1:5] have?
  1. Write the statement that reads the next line of Words.txt into NextWord.
  1. Why start the largest value at the first element of an array?
  1. In Python, how do you write the pseudocode element Board[1, 3] of a list of lists board?
  1. A file is opened FOR READ. Can the program write to it before closing it?

Sources

  • Cambridge International, IGCSE Computer Science 0478 syllabus for 2026 to 2028, units 8.2 and 8.3 and section 4 (pseudocode).
← All Notes
← Procedures, Functions and Strings: Quick RevisionDatabase Tables and Keys: Quick Revision →
More onComputer Science › Programming

Discussion (0)

Log in to join the discussion.

Loading…

On this page

  1. Arrays
  2. Loops over arrays
  3. Files
  4. Practice with new numbers
  5. A program to try
  6. Mistakes to avoid
  7. Check yourself
  8. Sources

Goes with the lesson

  1. Reading and writing filesArrays and Files in Pseudocode

More notes on this topic

Procedures, Functions and Strings: Quick Revision
  • Variables, Selection and Loops: Quick Revision
  • Logic Circuits and Truth Tables: Quick Revision
  • NAND, NOR and XOR Gates: Quick Revision
  • NOT, AND and OR Gates: Quick Revision
  • All notes on this topic →