2.2.2
Data Types
Choosing the right data type helps a program store values accurately and use memory sensibly. You need to recognise the common data types, choose suitable ones for a scenario, and understand casting when data needs to be changed temporarily from one type to another.
On this page6 sectionsHide
What you need to know
- Recognise integer, real, Boolean, character, and string data types.
- Choose the most suitable data type for a scenario.
- Explain what casting is and when it is useful.
Core Types
The data types you need to know
A strong exam answer often includes both the name of the data type and the reason it fits the situation.

| Data type | Stores | Example |
|---|---|---|
| Integer | Whole numbers | 27 |
| Real | Numbers with decimals | 3.14 |
| Boolean | True or false | True |
| Character | A single character | 'A' |
| String | A sequence of characters | "Hello" |
High-Value Exam Skill
Choosing the right type for a scenario
Think about what kind of value is being stored and what operations need to be done with it.
- Use integer for counts and whole-number quantities.
- Use real for measurements that may include decimals.
- Use Boolean for yes or no decisions.
- Use character for one symbol and string for text.
Conversions
Casting
Casting means converting a value from one data type to another.
This is useful when input arrives as text but needs to be used in a calculation, or when a number needs to be turned into text for output.
Common example
If a user enters age as text, the program may cast it to an integer before using it in a calculation.
Key takeaways
- Different types of data need different data types.
- Integers are whole numbers, while reals can include decimal values.
- Booleans store true or false values.
- Casting changes a value from one type to another temporarily or deliberately.
Glossary
- Integer
- A whole number data type.
- Real
- A data type that can store decimal values.
- Boolean
- A data type that stores True or False.
- String
- A sequence of characters.
- Casting
- Converting data from one type to another.
Test yourself
4 questions
What data type would you use for a test score of 87?
Integer.
What data type would you use for a temperature of 21.5?
Real.
What does a Boolean store?
True or False.
What is casting?
Changing a value from one data type to another.
Common questions
Why does choosing the right data type matter?
Because it helps the program handle values correctly and avoids unnecessary mistakes or wasted memory.
What is the difference between a character and a string?
A character stores one symbol, while a string stores a sequence of characters.
Why might a program need casting?
Because some values need to change type before they can be used correctly, such as text input being turned into a number.