Single lesson · Written for OCR J277

2D arrays – OCR GCSE Computer Science lesson (J277)

Pupils learn to declare a 2D array, read and change an element using its row and column indexes, and use nested FOR loops to process every element.

Also in a bundle Characters, Images, Sound, Strings and Arrays – OCR GCSE Computer Science lessons (J277) 11 lessons for £39 · save 11% on buying separately

Lesson 8 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 a program store a table of data?

By the end, pupils can declare a 2D array, read and change an element using its row and column indexes, and use nested FOR loops to process every element.

The Build (the main task)
Write a program that stores the campsite map as a 2D array of 3 rows × 4 pitches ("F" = free, "T" = taken), using the map shown. It should input a row index and a pitch index, book that pitch by changing it to "T", then use nested FOR loops to count and print how many pitches are still free.
Support version
Part-filled code: the 2D array and both loops are given with gaps for the two indexes and the counting line.
Challenge
Refuse a booking if the pitch is already taken, and print the map row by row with its row number.
Real-world link
The campsite map is a grid of pitches, each free or taken.
Key words
2D array, Index and Grid, each with a definition, an icon and a common mix-up on the key vocabulary slide.
Misconceptions it tackles
“camp[2][1] means column 2, row 1”; “camp[1] gives one pitch”.
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 all

Written for the specifications named. Not endorsed by or affiliated with any exam board.