Arrays: one name, many values
Watch the whole lecture free
Make a free account to watch every lecture to the end: 7 practice questions, 2 real past-paper questions with the answers explained, the mistakes that lose marks, the full-marks tip, a one-card summary and a quick quiz.
That was the teaching part. The rest of this lecture is free with an account: 7 practice questions, 2 real past-paper questions with the answers explained, the mistakes that lose marks, the full-marks tip, a one-card summary and a quick quiz.
No password needed now: we email you a link to set one. Already have an account? Sign in, then come back to this page.
The teaching part (1 min) is free to watch. A free account opens the whole lecture: 7 practice questions, 2 real past-paper questions with the answers explained, the mistakes that lose marks, the full-marks tip, a one-card summary and a quick quiz.
What this lecture covers
- Thirty variables?
- What is an array?
- Declare, fill, read
- Seven days of data
Read the transcript of the teaching part
Last time
Before we start: last time, in Strings, procedures and functions, you learned these points. Here they are again on one card. Keep them in mind, because today builds on them.
Thirty variables?
A teacher wants to store thirty marks. Thirty separate variables would be a nightmare to write, and impossible to loop through. An array gives them all one name, and a position number for each. Then one loop can process every one of them.
What is an array?
An array is a data structure that holds a fixed number of elements, all of the same data type. All the elements are stored under a single identifier. Each element is found using its index, its position number, which starts at one here. A loop can then process every element, so the code is short and easy to change.
Declare, fill, read
The declaration gives the name, the lower and upper bounds, and the data type. A FOR loop fills each element, with the counter as the index. Temps of three gives the third value directly.
Seven days of data
Here are seven daily temperatures. Day one is twenty-eight, day two thirty-one, day three thirty-three. Day five is thirty-five, the hottest.
How often it comes up
The whole chapter: Arrays.
Chapter 8.2: Arrays
- Arrays: one name, many values 6 min
Also for IGCSE Computer Science 0478
Which topics come up most in IGCSE Computer Science 0478 past papers, counted from every paper since 2004: Paper 1 topic frequency, Paper 2 topic frequency.