What data types and data structures does a National 5 program use, and when is each one chosen?
Data types and structures: variables holding character, string, numeric (integer and real) and Boolean values, and the 1-D array as a structure for holding many values of the same type under one name.
An SQA National 5 Computing Science answer on data types and structures, covering the variable types of character, string, integer, real and Boolean, when each is chosen, and how a one-dimensional array stores many values of the same type under a single name accessed by an index.
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 key area is asking
The SQA wants you to choose the right data type for a value (character, string, integer, real or Boolean) and to understand the one-dimensional array as a structure for holding many values of the same type under a single name.
Variables and data types
National 5 uses five data types:
- Character - a single symbol, such as
A,7or?. - String - a sequence of characters, such as
"Glasgow"or a person's name. A string can be empty or hold many characters. - Integer - a whole number with no fractional part, such as
42or-7. Used for counts, ages and positions. - Real (also called float) - a number with a decimal or fractional part, such as
3.14or-0.5. Used for measurements, averages and money. - Boolean - a value that is either true or false. Used for yes/no facts, such as whether a box is ticked.
Choosing the right type matters. An age in whole years should be an integer; an average mark should be a real because it can have a decimal part; a name should be a string; a "has paid?" answer should be a Boolean. Picking the wrong type either wastes memory or makes the value impossible to store correctly.
The one-dimensional array
When a program needs many values of the same type - thirty pupil marks, a list of temperatures, the names in a class - using a separate variable for each is clumsy. An array solves this.
If marks is an array, marks[0] is the first element, marks[1] the second, and so on (most languages start indexing at 0). To total every mark you do not write thirty lines; you write one loop that runs through each index and adds marks[index].
Why arrays make programs better
An array stores a whole list under one name, so the program needs one identifier instead of many. Each element is reached by an index, so a single loop can read or change every value. The same code works whether there are five values or five hundred, so the program is shorter, easier to read and easier to maintain. These are exactly the advantages a question about "why use an array" is looking for.
How this key area is examined
Questions give a scenario and ask you to state the most suitable data type for each value, declare a variable or array, or explain the advantage of using an array. For data types, match the kind of value to the type (whole number to integer, decimal to real, text to string, true/false to Boolean). For arrays, stress the single name, the index, and the loop that processes every element.
For the official course specification
The SQA publishes the full National 5 Computing Science course specification, specimen question papers and coursework tasks at sqa.org.uk. Always revise from the current specification and SQA past papers, because question style and terminology are board-specific.
Exam-style practice questions
Practice questions written in the style of SQA exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.
SQA N5 style4 marksA program stores: a pupil's name, their age in whole years, their average mark to one decimal place, and whether they have paid a trip deposit. State the most suitable data type for each.Show worked answer →
Four items, one mark each, so state the correct type for every one.
Name: string (a sequence of characters).
Age in whole years: integer (a whole number).
Average mark to one decimal place: real (a number with a decimal/fractional part).
Whether they have paid: Boolean (true or false).
Markers reward matching the type to the kind of value: whole numbers are integers, numbers with decimals are reals, text is a string, and a yes/no or true/false fact is Boolean. Choosing real for the age, or string for the deposit answer, would lose that mark.
SQA N5 style3 marksExplain why an array is more suitable than 30 separate variables for storing the marks of 30 pupils.Show worked answer →
Three marks for three clear advantages of an array.
An array stores all 30 marks under one name, so the program does not need 30 different variable names.
Each mark can be reached using an index (a position number), so a single loop can process every element in turn instead of writing code 30 times.
It is easy to change the number of pupils, because the same loop and array handle any size, which makes the program shorter, clearer and easier to maintain. Any three of these points gain the marks.
Related dot points
- Computational constructs: assignment, arithmetic, comparison and logical operators, concatenation, predefined functions, and the control structures of selection and iteration (fixed and conditional).
An SQA National 5 Computing Science answer on computational constructs, covering assignment, arithmetic, comparison and logical operators, string concatenation, predefined functions, and the control structures of selection (IF) and iteration (fixed and conditional loops) used to build programs in a high-level language.
- Standard algorithms: input validation, running total within a loop, and traversing a 1-D array, each as a reusable pattern built from selection and iteration.
An SQA National 5 Computing Science answer on the three standard algorithms, covering input validation with a conditional loop, keeping a running total inside a loop, and traversing a one-dimensional array with a fixed loop, with worked code-style examples of each reusable pattern.
- Analysis: identifying the purpose, scope and boundaries of a problem and writing functional requirements in terms of inputs, processes and outputs.
An SQA National 5 Computing Science answer on the analysis stage of software development, covering how to identify the purpose, scope and boundaries of a problem and how to write functional requirements in terms of the inputs, processes and outputs a finished program must provide.
- Design techniques: representing a program design with structure diagrams, flowcharts and pseudocode, and designing the user interface with a wireframe.
An SQA National 5 Computing Science answer on design techniques, covering how developers plan a program using structure diagrams, flowcharts and pseudocode, how to read and write each notation, and how a wireframe is used to design the layout of a user interface before coding begins.
- Data representation in a computer system: storing positive integers, real numbers and characters in binary, and the units used to measure storage from the bit upwards.
An SQA National 5 Computing Science answer on data representation in computer systems, covering how positive integers, real numbers (floating point) and characters are stored in binary, the meaning of bit and byte, and the units of storage scaling up through kilobyte, megabyte, gigabyte and terabyte.