← IGCSE Computer Science 0478 — 8.2 Arrays

IGCSE Computer Science 0478 — 8.2 Arrays Hangman

Years 10–11 · IGCSE · 36 key terms.

Theme
Words

Every word, shuffled.

Players

Storing many values under one name. See the whole journey →

Want your own words? Free Hangman Generator →

Same words, on paper

The quiet activity after the loud one. Free to print, answer keys included.

Crossword8.2 Arrays · 8.2 Arrays · 8.2 Arrays · all 5

Word search8.2 Arrays · 8.1c Procedures and Functions and 8.2 Arrays · 8.2 Arrays and 8.3 File Handling

Worksheetfor any module, with answer key

When your class is on devices — Snake Break and Diamond Dash run on the same modules, with a free class.

The 36 key terms

1ARRAY
An array stores many values of the same type under one name, so you need one array instead of many variables. An index reaches each value, and loops can process them all.
3ARRAY[1:30]
In ARRAY[l:u], l is the lower bound (index of the first element) and u is the upper bound (index of the last). Here the lower bound is 1 and the upper bound is 30.
4ARRAY[1:30] OF INTEGER
An array has a fixed size set when it is declared, and every element must be the same data type, so STRING and INTEGER cannot be mixed in one array.
5DECLARE StudentNames : ARRAY[1:30] OF STRING
Declares a 1D array named StudentNames with indexes 1 to 30 (lower:upper), each element holding a STRING. It only sets up the array; no values are stored yet.
6ARRAY[1:10] OF INTEGER
The data type after OF decides what every element can hold. ARRAY[1:10] OF INTEGER holds ten whole-number scores; REAL, CHAR, STRING or BOOLEAN would hold other kinds of data.
8upper - lower + 1
The number of elements in a 1D array: upper bound minus lower bound plus one. ARRAY[0:9] holds 9 - 0 + 1 = 10 elements, and ARRAY[5:9] holds 5.
9meaningful identifier
An array name that says what its elements hold, like StudentNames not A. It must never be a keyword such as INPUT or FOR, and upper or lower case makes no difference.
10StudentNames[1] ← "Ali"
Stores a value in one array element using the assignment operator ←. The value must match the array's data type, and it replaces any old value already in that element.
11OUTPUT StudentNames[1]
Reading an element: Name[index] in OUTPUT or an expression gives the value stored in that element. Reading only uses the value, so the element stays unchanged.
12Marks[Index]
A variable inside the brackets picks the element whose index matches its value. Change Index (an INTEGER) and the same statement reaches a different element of Marks.
13Array[n+1]
An index can be an expression like n+1. The expression is worked out first, then that element is used. It must stay within the array's bounds. Example: n=3 gives Array[4].
14index out of range
An error caused by using an index below the lower bound or above the upper bound, so the element does not exist. Example: Marks[31] in ARRAY[1:30] or Marks[0] when the lower bound is 1.
15FOR Index ← 1 TO 30
A count-controlled loop. It repeats the indented statements once for each value of Index, from 1 up to 30, going up by 1 each time. NEXT Index closes the loop.
17FOR Index ← 0 TO 29
For ARRAY[0:29], the loop must start at the lower bound 0 and end at the upper bound 29. It then visits all 30 elements and never goes outside the array.
18INPUT Name[Index]
Inside a FOR loop, INPUT Name[Index] stores each value the user types into the next array element, because Index changes every time the loop repeats.
19OUTPUT StudentNames[Index]
Inside a FOR loop, this line displays every element of the array in order. Index changes on each pass, so each pass outputs the next element, from the lower bound to the upper bound.
20Total ← Total + Marks[Index]
Adds the current element to the running total on each loop pass. Set Total ← 0 before the loop first, or the answer will be wrong. Divide by the number of elements for the average.
21IF Marks[Index] >= 50 THEN Count ← Count + 1
An IF inside the loop tests each element and adds 1 to Count when true. Set Count to 0 before the loop. A counter counts matches; a total adds up values.
22Largest ← Marks[1]
Start by assuming the first element is the largest, then compare every other element and replace Largest when a bigger one is found.
23linear search
A loop checks every element against the wanted value. On a match, set Found to TRUE and record the index. If Found is still FALSE at the end, OUTPUT a not found message.
24parallel arrays
Two or more arrays of the same size where the same index holds related data, e.g. StudentNames[3] and Marks[3] both describe the same student.
25trace table
A table that records the loop variable, index and array contents after each pass of a loop, so you can predict the final OUTPUT and spot errors such as off-by-one.
262D array
A table of rows and columns held in one variable. Each element needs two indexes: the first is the row (across), the second is the column (down), e.g. Marks[2, 3].
27DECLARE Grid : ARRAY[1:3, 1:3] OF CHAR
Declares a 2D array called Grid. The first range is the rows, the second is the columns, split by a comma. All elements share one data type, here CHAR.
28rows * columns
The total number of elements in a 2D array. Each dimension holds upper - lower + 1 values, so ARRAY[1:3, 1:3] holds 3 * 3 = 9 and ARRAY[1:30, 1:4] holds 30 * 4 = 120.
29Name[row, column] ← value
Stores a value in one element of a 2D array. Give the row index first, then the column index, e.g. NoughtsAndCrosses[2,3] ← 'X' puts a CHAR in row 2, column 3.
30Name[row, column]
Gives the value stored at that row and column of a 2D array. Use it in an expression or OUTPUT, e.g. OUTPUT NoughtsAndCrosses[2,3] shows the value at row 2, column 3.
31Grid[Row, Column]
Uses two variables as the row and column indexes, so one statement can reach any element of a 2D array. Both variables must stay within their bounds.
32nested FOR loop
A FOR loop for the columns placed inside a FOR loop for the rows. The inner loop runs fully for each row, so every element of a 2D array is visited and given a value.
33INPUT Marks[Student, Test]
Inside nested FOR loops, this reads a typed value into one cell of a 2D array. The inner loop fills a whole row before the outer loop moves to the next row.
34OUTPUT Name[Row, Column]
Placed inside nested FOR loops (outer loop for rows, inner loop for columns), this line displays each element of a 2D array once, in row order.
35Total ← Total + Marks[Row, Column]
Adds each element to a running total inside nested loops. Set Total to 0 first: before the loops for a grand total, or inside the outer loop for each row or column total.
36IF Grid[Row, Column] = Wanted THEN
Inside nested FOR loops, this compares each 2D array element with the wanted value; when it matches, store Row and Column as FoundRow and FoundColumn.
381D or 2D array
Use a 1D array for a simple list of values. Use a 2D array when data forms a table or grid, so each value needs two indexes: a row and a column.
39common array mistakes
Typical bugs: loop limits not matching ARRAY[l:u], swapped row and column indexes, a total not reset to 0, or the wrong data type stored. Check bounds, index order and starting values.
40DECLARE, FOR INPUT, FOR OUTPUT
The pattern of a complete array program: declare the array, use a FOR loop to INPUT a value into each element, then use a second FOR loop to OUTPUT every element.

Frequently Asked Questions

Do I need an account?

No. Hangman runs straight from this page — no account, no sign-up, nothing to install. If you add your class names, they are saved in your own browser and never sent to Cloodit.

How do I play it with my class?

Put the page on your whiteboard or projector and press Play. The class calls out letters and you click or type them. Six wrong letters and the word gets away. After every word its definition appears, so each round ends on the meaning, not just the spelling.

Can I use my own words?

Yes. The free Hangman generator at cloodit.com/hangman/ takes any list: one word or phrase per line, with a definition after a dash if you want it shown at the end of the round.

Can I put my students' names in?

Yes. Add your class list and a random student is called for each word. The list stays in this browser on this computer, so it is still there next lesson.

Are the worksheets free too?

Yes. Every module in this journey has a free printable worksheet with a full answer key, and there are crosswords and word searches built from the same key terms.

More IGCSE Hangman

IGCSE Computer Science 0478 — 1.1 Number Systems23 key terms IGCSE Computer Science 0478 — 1.2 Text, Sound and Images20 key terms IGCSE Computer Science 0478 — 1.3 Data Storage and Compression45 key terms IGCSE Computer Science 0478 — 2.1 Data Transmission Types and Methods36 key terms IGCSE Computer Science 0478 — 2.2 Methods of Error Detection39 key terms IGCSE Computer Science 0478 — 2.3 Encryption19 key terms Make your own hangman →Paste any word list and play