What is an array, and how do you store and process many values with one?
Arrays as a data structure: declaring and using one-dimensional arrays, accessing elements by index, and iterating through an array with a loop, with awareness of two-dimensional arrays.
An Eduqas GCSE Computer Science answer on arrays as a data structure: declaring and using one-dimensional arrays, accessing elements by index, iterating through an array with a loop, and awareness of two-dimensional arrays.
Reviewed by: AI editorial process; not yet individually human-reviewed
Have a quick question? Jump to the Q&A page
Jump to a section
What this dot point is asking
Eduqas wants you to explain what an array is, declare and use a one-dimensional array, access elements by index, and iterate through an array with a loop, with awareness of two-dimensional arrays. Writing a short algorithm that fills and processes an array (such as finding the largest value) is a common Component 1 and Component 2 task.
What an array is
Accessing and changing elements
scores = [0, 0, 0, 0, 0]
scores[0] = 88
scores[1] = 72
output scores[0] // outputs 88
Iterating through an array
Two-dimensional arrays
A two-dimensional array stores values in a grid of rows and columns, useful for tables such as a class's marks across several tests. You access an element with two indexes, one for the row and one for the column, for example grid[1][3]. At GCSE the main expectation is one-dimensional arrays, with awareness that two-dimensional arrays exist for grid-like data.
Try this
Q1. State what an array is. [1 mark]
- Cue. A data structure that stores many values of the same data type under one identifier, each accessed by an index.
Q2. In an array data indexed from 0, state which element data[3] is. [1 mark]
- Cue. The fourth element (because indexing starts at 0).
Q3. State one advantage of an array over using separate variables for a list. [1 mark]
- Cue. A loop can process every element by index, so the code is shorter and scales to any size.
Exam-style practice questions
Practice questions written in the style of WJEC Eduqas exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.
Eduqas Component 1, 20224 marksExplain what an array is and why it is more efficient than using separate variables to store a list of 30 test scores.Show worked answer →
What an array is (up to 2 marks): a data structure that stores many values of the same data type under one identifier, each accessed by an index (position) number.
Why more efficient (up to 2 marks): instead of declaring 30 separate variables (score1, score2 and so on), you declare one array and use a loop to process all 30 by index, so the code is much shorter, and the size can be handled with a single loop rather than 30 lines.
Markers reward "same type, one name, accessed by index" and the point that a loop can process the whole array, which separate variables cannot.
Eduqas Component 1, 20235 marksWrite an algorithm that stores five numbers in an array, then outputs the largest of them.Show worked answer →
Read five numbers into an array, set the largest to the first element, then loop through comparing.
Read into numbers[0] to numbers[4]; largest = numbers[0]; for i = 1 to 4; if numbers[i] > largest then largest = numbers[i] endif; next i; output largest.
Marks: declaring/filling the array (1), initialising largest to the first element (1), looping through the rest (1), the comparison and update (1), outputting the largest (1).
Markers reward initialising from the first element and looping from index 1. Starting largest at 0 fails if all numbers are negative.
Related dot points
- The purpose and functions of an operating system (memory management, multitasking, peripheral management, the user interface, and security and user management) and the role of common utility software.
An Eduqas GCSE Computer Science answer on the purpose and functions of an operating system (memory management, multitasking, peripheral management, the user interface, security and user management) and the role of common utility software.
- Variables and constants, the common data types (integer, real, Boolean, character, string), and the arithmetic, relational and logical operators used in programs.
An Eduqas GCSE Computer Science answer on variables and constants, the common data types (integer, real, Boolean, character, string), and the arithmetic, relational and logical operators, including integer division and modulus.
- The three programming constructs: sequence, selection (if and nested if) and iteration (count-controlled and condition-controlled loops), and when to use each.
An Eduqas GCSE Computer Science answer on the three programming constructs: sequence, selection (if, else, nested if) and iteration (count-controlled for loops and condition-controlled while loops), with worked pseudocode for each.
- Subprograms (procedures and functions), the difference between them, parameters and arguments, local and global variables, and why subprograms make programs easier to write and maintain.
An Eduqas GCSE Computer Science answer on subprograms: the difference between a procedure and a function, parameters and arguments, local and global variables, and why subprograms support decomposition, reuse and easier maintenance.
- String handling (length, indexing, substrings, concatenation, case conversion), input validation (presence, range, length, type and format checks), and how programs are written and tested in the Component 2 on-screen exam.
An Eduqas GCSE Computer Science answer on string handling (length, indexing, substrings, concatenation, case conversion), input validation (presence, range, length, type, format), and how programs are written, tested and refined in the Component 2 on-screen exam.
Sources & how we know this
- WJEC Eduqas GCSE Computer Science specification (from 2016) — Eduqas (2020)