Declare and use one-dimensional arrays
Store a fixed-length sequence of values of the same type and access each value by index.
Section 8 · Programming
Exam scope and assessment notes
This sequence follows Cambridge IGCSE Computer Science 0984, 2026–2028 syllabus Version 4. It covers section 8.2 (Arrays) only. Pseudocode examples use the published Cambridge format; the separate 2029–2031 syllabus is not mapped here. Practice is original, self-checked and does not award an official Cambridge grade. Full timed papers, a browser-based programming workspace and human subject-teacher review remain outstanding. Cambridge states that 0984 has the same 2026–2028 subject content as 0478, with 9–1 grading. In June and November, Cambridge lists 0984 in Administrative zone 3 and for centres in Oman and the UAE. Confirm availability for your centre and exam series with Cambridge International. The separately published 2029–2031 syllabus changes to Python 3 only and removes pseudocode; this 2026–2028 route does not cover those changes.
Before you begin
- Be comfortable following an ordered algorithm and tracing variable values. Each lesson introduces the Cambridge pseudocode form it uses.
Work on paper. Try each question before revealing help, and explain why your method works.
Quick readiness check
What does the index in Marks[3] identify?
What you will learn
- Declare a one-dimensional array with bounds and type
- Read and assign an element by index
- Explain when a collection is useful
An array stores related values
An array is a fixed-length structure whose elements have the same data type. Declare its lower and upper bounds, then the element type.
For example, DECLARE Marks : ARRAY[1:5] OF INTEGER reserves five integer elements. The first index can be zero or one; state the lower bound rather than assuming it.
An index selects one element
Use square brackets to read or assign an individual element, such as Marks[1] ← 72. A variable can be used as an index when a loop chooses the element.
Arrays are useful when a program handles many related values with the same operation. They do not automatically validate that an index is inside the declared bounds.
Pause and explain
Which is a suitable declaration for 12 temperatures that may include decimals?
Worked example
Declare a one-dimensional array for 30 student names and store one name.
Show the worked solution
- The array contains 30 values of the same type.
- Use a lower bound of 1 and upper bound of 30.
- Assign a string into one indexed element.
Answer DECLARE StudentNames : ARRAY[1:30] OF STRING; StudentNames[1] ← "Ali".
Try a topic test
Choose Easy, Normal or Difficult. Save your answers and open worked review after finishing.
Test this topic →From guided practice to a new situation
Write your answer and reasoning first. Use a hint only if you are stuck. The model solution is for self-checking; your written work is not automatically marked.
Declare an array for 8 decimal measurements with indexes 0 to 7.
Give me a hint
Specify both bounds and the common type.
Compare my reasoning
- There are eight positions from 0 through 7.
- A decimal measurement needs REAL.
- Write the ARRAY declaration.
DECLARE Measurements : ARRAY[0:7] OF REAL.
Look for these in your work
- Bounds count
- REAL type
If Names is ARRAY[1:4] OF STRING, what does Names[3] ← "An" change?
Give me a hint
Only the element at index 3 is assigned.
Compare my reasoning
- It stores text in one element.
- It does not replace the whole array.
- The other indexes remain unchanged.
It sets the third indexed element to "An".
Look for these in your work
- Element identified
- Array scope understood
A routine loops from 0 to 5 over ARRAY[1:5] OF INTEGER. Identify the invalid access and correct the bounds.
Give me a hint
Compare the loop's smallest and largest indexes with the declaration.
Compare my reasoning
- Index 0 is below the declared lower bound.
- The loop also accesses indexes 1–5.
- Change the loop to 1 TO 5 or declare a zero-based array with six elements if that is intended.
Index 0 is invalid; use 1 TO 5 for the declared five-element array.
Look for these in your work
- Invalid index
- Consistent correction
Common mistakes
- Using an index outside the declared lower and upper bounds
- Storing mixed data types in one typed array
- Forgetting that the index base may be 0 or 1
What can you explain now?
If Marks is ARRAY[1:5] OF INTEGER, how many values can it store?
Compare with the explanation
Five integer values
The inclusive index range 1 through 5 contains five elements.
After trying it yourself, choose your next review. This is your self-assessment.
Your review choice appears on Today. Sign in to sync it across devices.
Make it stick
Why should an array's index bounds be stated explicitly?
If you needed the solution, close it and solve the problem again from a blank page. A correct answer is stronger when you can explain the reason for each step.