/en-tutor-prep-igcse-cs-programming-concepts-arrays-file-handling/
/en-tutor-prep-igcse-cs-programming-concepts-arrays-file-handling/
General Inquiry: info@TutorZone.com.hk
Office Hours: Monday to Saturday - 9:00 AM to 6:00 PM
WhatsApp Monday to Sunday - 24 hours
Hotline: +852 6828 1809
Instant Support: +852 9061 3106

IGCSE Computer Science: Programming Concepts, Arrays and Files — Tutor Prep Guide

IGCSE Computer Science: Programming Concepts, Arrays and Files — Tutor Prep Guide

  • 2026-11-27

Students forget declarations, mix data types, treat a two dimensional array as one dimensional, and freeze at the word file. This chapter compresses five data types, three operator groups and four string functions into three tables, fills a 30 by 5 array with 150 cells, then finishes with four commands for reading and writing a file.

Objectives — Students can: (1) choose the right basic type for four values and write both a DECLARE and a CONSTANT statement; (2) use DIV and MOD to split 47 students into groups of 5, giving 9 groups and 2 left over; (3) use LENGTH, SUBSTRING, UCASE and LCASE, for example cutting TutorZone into Tutor and Zone; (4) declare a 30 by 5 two dimensional array, fill 150 cells with nested loops and output one row per student; (5) write the four file commands in order and explain that WRITE clears the old file.

01 Prerequisites (3-minute check)

If any of these fails, fix it before the lesson starts.

Skill Quick check Pass mark
Variables and constants What is the difference between a variable and a constant? A variable can change while the program runs, a constant is set once and never changes
Integer and real What is 47 divided by 5? 9 remainder 2, or 9.4 with a slash
Repetition An action repeats 12 times. Which loop? A FOR count controlled loop, because the count is known

02 Lesson flow (60 minutes)

Time Stage Tutor does Student does
0-10 min Five types Pick a type for four values All of INTEGER, REAL, CHAR, STRING and BOOLEAN correct
10-20 min Declarations and operators Write DECLARE and CONSTANT, work DIV and MOD 9 groups, 2 left over
20-32 min String functions Cut TutorZone apart and change case Tutor and Zone, length 9
32-44 min Two dimensional array 30 by 5 with nested loops 150 cells, 30 output rows
44-54 min Four file commands Write a routine that reads 60 lines and writes them out All four commands, right modes
54-60 min Maintainability Rename identifiers and add comments All four features present

03 Teaching script (read it out)

Scene 1: Five basic types and two declarations – declare before you use

The five basic types must pair up instantly: INTEGER is a whole number, REAL has a fraction, CHAR is one character in single quotes, STRING is zero or more characters in double quotes, and BOOLEAN is TRUE or FALSE only. The cost of a wrong choice is concrete: marks stored as INTEGER truncate an average, and a price stored as INTEGER loses its pence.
Two declaration forms must be memorised: DECLARE then the identifier, a colon and the type; CONSTANT then the identifier, a left arrow and a literal. A constant may only hold a literal, never a variable or an expression. Identifiers use Pascal case, start with a capital letter, and contain only letters and digits, no underscore.
Know the count in each operator group: arithmetic has 7, add, subtract, divide, multiply, power, MOD and DIV; relational has 6; logical has 3, AND, OR and NOT. A relational operator always returns BOOLEAN, and both sides of a logical operator must already be BOOLEAN, which is the type error students make most.
Anchor it with one set of numbers: 47 students in groups of 5 gives DIV 9 groups and MOD 2 left over, and 9 times 5 plus 2 returns exactly 47. DIV for the quotient, MOD for the remainder, a plain slash for a real number: learn the three together.

Type Meaning Written as Typical use
INTEGER a whole number 47, -3, 0 student count, floor number
REAL a number with a fraction 4.7, 0.3, -4.0 average, temperature, price
CHAR one character in single quotes ‘x’, ‘@’ grade letter, category code
STRING zero or more characters in double quotes “Happy Days”, “” name, address
BOOLEAN true or false only TRUE, FALSE paid or not, pass or not
Group How many Demonstration
Arithmetic 7 in all: add, subtract, divide, multiply, power, MOD, DIV 47 students in groups of 5: DIV gives 9 groups, MOD leaves 2
Relational 6 in all: equal, less than, less or equal, greater, greater or equal, not equal The result is always BOOLEAN
Logical 3 in all: AND, OR, NOT Both sides must be BOOLEAN

Students pick a type for four values, write the declaration for each, then give the quotient and remainder of 47 divided by 5.

Scene 2: Strings, procedures and maintainability – put the repetition away

Strings have only four functions: LENGTH gives the length, SUBSTRING takes a slice, UCASE changes to capitals and LCASE to small letters. SUBSTRING takes three parameters, the string, the start position and the length, and the first character may be position 0 or 1, so the question always states which.
Demonstration: LENGTH of TutorZone is 9; SUBSTRING with start 1 and length 5 gives Tutor; start 6 and length 4 gives Zone; UCASE makes the whole thing capitals. With zero based positions the same slice needs start 0, so every position shifts down by one, and one answer must not mix the two conventions.
A function and a procedure differ in one sentence: a function returns a value, a procedure does not. A function is declared with RETURNS and a type, hands the value back with RETURN, and is never called with CALL; a procedure is called with CALL and the call is a complete statement. Both take at most three parameters, which the mark scheme enforces.
Local against global: declared inside a procedure means local and starts fresh on every call; declared at the top means global and any procedure may change it. Two procedures sharing one global counter corrupt each other, which is the standard debugging scenario.
Maintainability has four features: meaningful identifiers such as Total rather than T, comments, repeated logic captured in procedures and functions, and comments placed where the syntax is subtle rather than translating every line. Nesting stops at three levels; beyond that, extract a procedure.

Students rewrite a program with no comments and identifiers called a and b into a maintainable version, and say which part should become a function.

Scene 3: Arrays and files – handle a batch at a time

A one dimensional array is a row of cells, declared with both bounds: DECLARE Marks : ARRAY[1:30] OF INTEGER. A two dimensional array is a table with a bound pair per dimension: DECLARE ClassMarks : ARRAY[1:30, 1:5] OF INTEGER, which is 30 times 5, so 150 cells.
Filling it needs nested iteration: the outer loop runs 1 to 30 for students, the inner loop 1 to 5 for subjects, which is 150 writes, and reading it back is another 150. Indexes may be variables, so ClassMarks[Student, Subject] is legal; the first index may be 0 or 1, but the declaration and the use must agree, or the first or last cell runs out of bounds.
On files the syllabus has four commands and two modes: OPENFILE with a file name and FOR READ or FOR WRITE, READFILE to read one item into a variable, WRITEFILE to write one variable out, and CLOSEFILE to close. There is no APPEND, so FOR WRITE creates a new file and destroys the old contents, which is the easiest mark to lose: to add to an existing file in 0478 you read it in and write the whole lot out again.
Why use a file at all: 60 records retyped on every run at 20 seconds each is 1,200 seconds, which is 20 minutes; reading 60 lines at 0.01 seconds each is 0.6 seconds, 2,000 times faster. That contrast is the model answer for why data is stored in a file.

Students declare a 30 by 5 array, fill it with nested loops, then write 60 lines to a new file with the four commands.

04 Question types and worked steps

Type Example Steps Answer
Choose a type Student count, average mark, grade letter, paid or not Match each to INTEGER, REAL, CHAR or BOOLEAN all four of the 5 types in play
DIV and MOD 47 students in groups of 5 DIV for the quotient, MOD for the remainder 9 groups, 2 left
Write an array 30 students, 5 subjects Declare two dimensions, fill with nested loops 150 cells, 30 outer passes
Files Write 60 lines to a new file and read them back OPENFILE FOR WRITE, then FOR READ, then CLOSEFILE All four commands, right modes
Sanity check (teach this): Rationality checks: (1) the five types are INTEGER, REAL, CHAR, STRING and BOOLEAN, and nothing else; (2) a relational operator returns BOOLEAN, never a number; (3) DIV gives the quotient, MOD the remainder, a slash a real number, and none replaces another; (4) SUBSTRING takes string, start and length, with the first position 0 or 1 used consistently; (5) a function returns a value with RETURN and is never called with CALL, a procedure is called with CALL; (6) nesting stops at three levels and parameters at three; (7) files have only READ and WRITE, and WRITE clears the old file, since there is no APPEND; (8) 47 divided by 5 is 9 remainder 2, and 9 times 5 plus 2 restores 47.

05 Independent practice (3 questions)

Question Answer What to watch
47 students in groups of 5. Give the DIV and MOD results. DIV gives 9 groups, MOD leaves 2 Check whether quotient and remainder were swapped
30 students and 5 subjects. How many cells, and how many writes? 150 cells and 150 writes Check whether only one dimension was multiplied
Reading 60 lines at 0.01 seconds each. How many seconds? 0.6 seconds Check whether the number of records was used

06 Common mistakes and what to say

Mistake Student writes Say this
No declaration Just use Total, a value will arrive later Declare it with a type first, then initialise it; an undeclared variable is an error in a pseudocode answer.
DIV and MOD swapped 47 divided by 5 has remainder 9 DIV gives the quotient 9 and MOD the remainder 2, so label which is which while writing.
One index on a table ClassMarks[Student] holds all that student subjects Two dimensions need two indexes, ClassMarks[Student, Subject], with the inner loop over subjects.
Expecting an append Opening the old file FOR WRITE adds to the end There is no APPEND in 0478; FOR WRITE empties the file, so read it in and write everything back.

07 Homework (paper, section and question numbers)

08 Exit check (last 5 minutes)

Question Answer Decision
Five types INTEGER, REAL, CHAR, STRING, BOOLEAN Cannot say it, return to act one
DIV and MOD 47 divided by 5 is 9 remainder 2 Cannot say it, return to the end of act one
Four file commands OPENFILE, READFILE, WRITEFILE, CLOSEFILE, with READ and WRITE only Cannot say it, return to act three

09 Tutor FAQ

How do I get students to separate CHAR from STRING?

Look at the quotes and the count: CHAR is one character in single quotes, STRING is zero or many characters in double quotes. The practical test is whether more than one character could appear, and if so it is a STRING. Wrong quotes or a wrong type both lose marks, so fix the declaration and the quotes together.

How do I choose between a procedure and a function in an answer?

If a value comes back, it is a function, for example an average or a total; if it only does something, it is a procedure, for example printing or writing a file. A function declaration needs RETURNS and a type, and the body needs RETURN; a function call never uses CALL because it is not a complete statement.

Does the order of the nested loops matter?

Yes. The outer loop should be the rows, the students, and the inner loop the subjects, because most questions output one line per student, and the outer loop changing is what changes the student. The reverse order still fills every cell, but the output becomes one line per subject, so a question asking for each student total loses marks.

Find a tutor — freeTutor Registration →

A TutorZone lesson-prep guide. Written by the TutorZone team; questions and lesson flow are original and are not taken from any school or publisher material.

Join as a tutor or coach — academic, music, sports, arts, STEM. Free to register. See how it works →