📁 Topic 2 · 2.3 Data Types and Structures
2.3a Data types, variables and constants
Edexcel 4CP0 · iGCSE Computer Science · ~10 min read
Notes
──
Video
──
Slides
──
Worksheet
──
Quiz

Data Types

A data type defines what kind of data a variable can store and what operations can be performed on it. Choosing the correct data type is essential for writing correct and efficient programs.

Data TypeDescriptionExample values
IntegerWhole numbers (positive, negative, or zero)42, -7, 0, 100
Real (Float)Numbers with a decimal point3.14, -0.5, 9.81
BooleanCan only be TRUE or FALSETRUE, FALSE
Character (Char)A single letter, digit or symbol'A', '5', '!'
StringA sequence of zero or more characters"Hello", "4CP0", ""

Variables

A variable is a named location in memory that stores a value. The value stored in a variable can change during the execution of the program.

In Edexcel 4CP0 pseudocode, variables are assigned using:

SET variableName TO value

SET age TO 16
SET name TO "Alice"
SET isValid TO TRUE
SET price TO 9.99

Constants

A constant is a named value that is fixed and cannot change during program execution. Constants make programs easier to read and maintain — if the value needs to change, you only update it in one place.

CONST REAL PI = 3.14159
CONST INTEGER MAX_SCORE = 100
CONST REAL VAT_RATE = 0.20

Variables vs Constants

FeatureVariableConstant
Value can change?YesNo — fixed at declaration
Declared withSET … TO …CONST <type> … = …
Examplesscore, name, totalCONST REAL PI, CONST INTEGER MAX_SIZE
Use whenValue changes as program runsValue stays the same throughout

Type Casting

Sometimes you need to convert a value from one data type to another. This is called type casting. For example, converting the string "42" to the integer 42, or converting an integer to a string for output.

📝 Exam Tip: In Paper 1, you may be given code and asked to identify the data type of a variable. Look at the value assigned: "hello" = string, 42 = integer, 3.14 = real, TRUE/FALSE = boolean, 'A' = character.
⚠️ Common Mistakes
  • Confusing integer and real — "4" stored as a string is NOT an integer; "4.0" is a real, not an integer
  • Saying a boolean can store "yes/no" or "0/1" — in pseudocode it is TRUE or FALSE
  • Trying to perform arithmetic on a string — "5" + "3" = "53" (concatenation), not 8
← 2.2 Sequence, Selection, Iteration Topic 2 · 2.3 Data Types and Structures Next: 2.3b Data Structures →
🔒
Pro Content
Subscribe to access all 47 Edexcel iGCSE lessons.
£7.99/month
or £59/year