1D arrays – OCR GCSE Computer Science lesson (J277)
Pupils learn to declare a 1D array, read and change its elements by index, and use a FOR loop to process every element.
Lesson 5 of 11 in unit 10.4 Characters, Images, Sound, Strings and Arrays, taught in Year 10, Spring 2. It answers one big question: How can one variable hold a whole list of values?
By the end, pupils can declare a 1D array, read and change its elements by index, and use a FOR loop to process every element.
- The Build (the main task)
- Write a program that stores the day's sales for five food stalls in an array: 120, 85, 40, 210 and 95. Use a FOR loop to print each stall's position and sales and to add up the total, then print the total. Finally, let the user enter a stall's position and its new sales, change that array element, and print the array.
- Support version
- Part-filled code: the array, the loop and the total line are given with gaps for the index, the loop's range and the update line.
- Challenge
- Extend the program to find and print the stall with the highest sales using a loop, without max().
- Real-world link
- The app stores the day's ticket sales for each food stall in one array.
- Key words
- Array, Array element and Position, each with a definition, an icon and a common mix-up on the key vocabulary slide.
- Misconceptions it tackles
- “The first element of an array is stalls[1]”; “stalls[2] = 90 adds a new element to the array”.
- OCR J277 specification
- 2.2.3 (additional programming techniques: string manipulation (length, case, substrings, concatenation, ASCII conversion) and 1D and 2D arrays).
Every lesson follows the same Code & Commerce structure: a Bell Task recall starter, key vocabulary with definitions and icons, short teaching chunks with a check before pupils move on, The Build (one main task), challenge questions that get harder, and an exit question. Answers reveal one at a time on the slides, and everything is editable PowerPoint and Word.
Pupils need computers for the main task.
Also sold in the Characters, Images, Sound, Strings and Arrays unit bundle, which includes the medium term plan, and in the full-year and complete-course bundles.
What's included
- Slide deck (PowerPoint)
- Lesson plan (Word)
- Worksheet (Word)
- Support worksheet with scaffolds (Word)
- Single-teacher licence: use and adapt it with your own classes
More for GCSE Computer Science (OCR)
See allPupils learn to explain how a character set gives each character a binary code, encode and decode text with ASCII, and compare ASCII and Unicode by bits per character and range.
Free sample lessonPupils learn to use concatenation, length, slicing, upper and lower case and ASCII conversion in Python and OCR Exam Reference Language to build and extract parts of strings.
Pupils learn to explain how a bitmap image is stored as pixels with binary colour codes, and describe how colour depth and resolution affect quality and file size.
Written for the specifications named. Not endorsed by or affiliated with any exam board.