Unable to open this exercise
Common exam pitfall
Students often forget the ARRAY[1:N] OF type syntax, writing array sizes in parentheses or omitting the OF keyword.
A One-Dimensional (1D) Array is a static data structure holding a fixed collection of elements of the same data type, referenced under a single identifier and accessed via an integer index.
1. Array Declaration in Cambridge Pseudocode
DECLARE <Identifier> : ARRAY[<LowerBound>:<UpperBound>] OF <DataType>
Key Declaration Rules:
- Enclose the bounds inside square brackets
[...]. - Separate lower and upper bounds with a colon
:. - Follow the declared bounds;
[1:50]has 50 elements and[0:49]also has 50. - Specify the type with the
OFkeyword (e.g.OF INTEGER,OF STRING).
2. Accessing and Manipulating Array Elements
Individual elements are read or written using square bracket index notation:
DECLARE Grades : ARRAY[1:5] OF CHAR
// Direct assignment
Grades[1] <- 'A'
Grades[2] <- 'B'
// Iterative input
FOR i <- 1 TO 5
INPUT Grades[i]
NEXT i
Exam Warning: Attempting to read or write to Grades[0] or Grades[6] triggers an Array Index Out of Bounds runtime error.
Declared bounds matter
Arrays can be declared with different lower bounds. ARRAY[0:4] contains five elements just as ARRAY[1:5] does. Use the declared bounds in loops; index zero is not universally forbidden. Our examples usually start at 1 for consistency.
AI Socratic Tutor
Need guidance? Ask a question or use the hint below.
AI Socratic Tutor is an All-Access Benefit
Unlock step-by-step Socratic hints, algorithm trace table walkthroughs, and error diagnostics for every Cambridge exercise.
You're chatting with an AI tutor, not a person. AI can make mistakes, so double-check its answers.
Exam-Style Check: Cambridge 1D Array Declaration Syntax
• Multiple ChoiceWhich statement is the correct Cambridge pseudocode declaration for a one-dimensional array storing 20 real temperature readings?
Interactive exercises for Module 2 and beyond require an active plan.