StudyVault
Home Unit Overview Exam Technique Revision Techniques ← Previous Lesson Next Lesson →

← Back to Dashboard

Overlay:
0:00 / 0:00 Narration generated using AI text-to-speech.

Data Types and Programming Constructs

Why Data Types Matter

Every piece of data stored in a program has a data type. Choosing the right type is not just a technical formality — it determines what you can do with the data. You cannot multiply two text strings. You cannot store the word “open” as a Boolean. Getting the type wrong leads to errors that are often hard to diagnose. The specification names five data types you must know.

Key Fact

The five data types are: integer (whole number, e.g. 7 or −3), real (number with a decimal point, e.g. 3.14 or −0.5), Boolean (true or false only), character (a single symbol, e.g. ‘A’ or ‘?’), and string (a sequence of characters, e.g. “hello” or “12 Oak Road”).

The Five Data Types

An integer stores a whole number. Examples: a person’s age, a score in a game, the number of students in a class. Integers support the full range of arithmetic operations.

A real number stores values that can have a fractional part. Examples: a temperature reading (36.7), a price (£12.99), a percentage (78.5). Some languages call this type ‘float’ — but in your exam you should use the term ‘real’.

A Boolean holds only one of two values: true or false. Examples: whether a light is on or off, whether a user is logged in, whether a password matches. Boolean conditions are central to all selection and iteration.

A character stores exactly one symbol — a letter, digit, space or punctuation mark. Stored in single quotes: ‘A’, ‘9’, ‘!’. A string is a sequence of characters of any length, including zero (an empty string). Stored in double quotes: “hello”, “password123”, “” (empty).

When a user types a number into a program, it arrives as a string by default. If you try to add two numbers that are stored as strings, you get concatenation instead of addition. For example: “5” + “3” gives “53” (text joined together), not 8 (arithmetic sum). You must convert the input to an integer or real before performing arithmetic. In exam questions, always check whether the variable storing a user’s input is the right type for the intended operation.

Variables and Constants

A variable is a named location in memory whose value can change while the program runs. In AQA pseudo-code, you declare and assign a variable in one step: score ← 0. Every variable has a name (its identifier), a value, and a data type.

A constant is similar, but its value is fixed for the entire program. Example: MAX_ATTEMPTS ← 3. Constants are typically written in uppercase to signal that their value must not be changed. Using named constants makes code easier to maintain — if you need to change the maximum number of login attempts from 3 to 5, you change it in one place rather than finding every occurrence of the number 3 in your code.

Key Fact

Meaningful identifier names make code readable and maintainable. examScore is immediately clear; x or temp123 is not. The specification says you must use meaningful names when you write programs in the exam. A single-letter name, apart from a loop counter such as i, does not tell a reader what the variable is for.

The Three Programming Constructs

Every program, regardless of language, is built from three fundamental constructs: sequence, selection, and iteration. These are the only three building blocks needed to solve any computable problem.

Sequence — instructions execute in order, line by line:

name ← USERINPUT
OUTPUT “Hello, ” + name

Selection — the program makes a decision:

score ← USERINPUT
IF score ≥ 70 THEN
  grade ← “Merit”
ELSE
  grade ← “Pass”
ENDIF
OUTPUT grade

Iteration — a block of code repeats:

FOR i ← 1 TO 5
  OUTPUT i
ENDFOR

Outputs: 1, 2, 3, 4, 5

DIV and MOD Operators

Two arithmetic operators you must know are DIV and MOD. DIV performs integer division and returns the whole-number quotient. MOD returns the remainder. For example: 17 DIV 5 gives 3 (because 5 goes into 17 three full times). 17 MOD 5 gives 2 (because 17 = 3 × 5 + 2). These operators appear frequently in exam questions because they are used to test whether a number is odd or even (n MOD 2 = 0 means even), to extract individual digits, and to create circular patterns in data structures.

Practice Questions

Test yourself on this lesson. Pick a question, write your answer, then get it marked.

AI feedback
AI feedback is guidance, not a final exam mark. If you disagree, your teacher's view is always the tie-breaker.
← Back to unit
Video

© 2026 StudyVault · About · FAQ · Copyright & IP · Privacy · Disclaimers

StudyVault Education Ltd · registered in England and Wales, company no. 17490559 · 71–75 Shelton Street, London WC2H 9JQ