# Variables, Constants &amp; Data Types

> Cambridge Assessment International Education (CAIE) Pseudocode Reference Guide
> Applicable Syllabus: **IGCSE &amp; A Level**

Cambridge pseudocode variable declarations, INTEGER, REAL, CHAR, STRING, BOOLEAN, DATE data types, CONSTANT definitions, and arrow (&lt;-) assignments.

---

All variables must be declared using `DECLARE` with an explicit data type. Constants use `CONSTANT`. The assignment operator is `&lt;-`.

### Data Types

| Data Type | Description | Literal Examples |
|-----------|-------------|------------------|
| `INTEGER` | A whole number | `5`, `-3` |
| `REAL` | A number with a fractional part | `4.7`, `0.3`, `-4.0`, `0.0` |
| `CHAR` | A single character | `&#39;x&#39;`, `&#39;C&#39;`, `&#39;@&#39;` |
| `STRING` | A sequence of zero or more characters | `&quot;Hello&quot;`, `&quot;&quot;` |
| `BOOLEAN` | Logical values | `TRUE`, `FALSE` |
| `DATE` | A valid calendar date | `dd/mm/yyyy` |

### Variable &amp; Constant Declarations

```pseudocode
// runnable
DECLARE Counter : INTEGER
DECLARE TotalToPay : REAL
DECLARE GameOver : BOOLEAN
DECLARE Initial : CHAR
DECLARE StudentName : STRING

// Comma-separated declarations are also supported per exam mark schemes
DECLARE Low, High, Mid, Target : INTEGER

CONSTANT HourlyRate = 6.50
CONSTANT DefaultText = &quot;N/A&quot;
```

### Assignments

```pseudocode
// runnable
// Assignment demo
DECLARE Counter : INTEGER
DECLARE TotalToPay, NumberOfHours : REAL
CONSTANT HourlyRate = 6.50
NumberOfHours &lt;- 4
// The assignment operator is &lt;-
Counter &lt;- 0
Counter &lt;- Counter + 1
TotalToPay &lt;- NumberOfHours * HourlyRate
OUTPUT TotalToPay
```

### Identifier Rules

- Can contain letters (A-Z, a-z), digits (0-9), and underscore (_)
- Must start with a letter, not a digit
- Should be considered case insensitive
- Keywords must never be used as variable names
- Use descriptive names (e.g. `NumberOfPlayers`) — single letters are acceptable for loop conventions (e.g. `i`, `j` for array indices)


---

* Previous Topic: [Pseudocode in Examined Components](https://csmasters.dev/docs/pseudocode/exam-conventions.md)
* Next Topic: [Arrays (1-Based Indexing)](https://csmasters.dev/docs/pseudocode/arrays.md)
