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 Type | Description | Example values |
|---|---|---|
| Integer | Whole numbers (positive, negative, or zero) | 42, -7, 0, 100 |
| Real (Float) | Numbers with a decimal point | 3.14, -0.5, 9.81 |
| Boolean | Can only be TRUE or FALSE | TRUE, FALSE |
| Character (Char) | A single letter, digit or symbol | 'A', '5', '!' |
| String | A sequence of zero or more characters | "Hello", "4CP0", "" |
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:
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.
| Feature | Variable | Constant |
|---|---|---|
| Value can change? | Yes | No — fixed at declaration |
| Declared with | SET … TO … | CONST <type> … = … |
| Examples | score, name, total | CONST REAL PI, CONST INTEGER MAX_SIZE |
| Use when | Value changes as program runs | Value stays the same throughout |
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.