Master Pseudocode with Pro
Get unlimited access to the AI Tutor, Code Generator, and Converters. Plus, enjoy an ad-free experience.
Variables in Pseudocode: The Ultimate Guide
Variables are the absolute foundation of programming. Think of them as named storage boxes in your computer's memory. When you create a variable, you are reserving a specific space to store data that can change (vary) while your program is running.
Whether you are preparing for CIE (9618), AQA (8520), OCR, or IB exams, correct variable handling is tested in almost every question. This guide provides a deep dive into declaration, assignment, data types, and scope across all major exam boards.
Table of Contents
Core Concepts: Working with Data
A variable is effectively a pointer to a location in memory. In pseudocode, we use descriptive identifiers (names) so humans can easily understand what data is being tracked. Let's look at the properties that define variables.
Understanding Data Types
Before you can declare a variable, you must understand what you are storing. Different data requires different amounts of memory and allows for different operations. For example, you can perform math on an INTEGER, but not on a STRING.
| Data Type | Description | Examples |
|---|---|---|
| INTEGER | Whole numbers without fractions. | 5, -10, 0 |
| REAL / FLOAT | Numbers with decimal points. | 3.14, 10.5, -0.01 |
| CHAR | A single alphanumeric character. | 'A', '1', '@' |
| STRING | A sequence of characters (text). | "Hello", "User123" |
| BOOLEAN | Logical values representing truth. | TRUE, FALSE |
Declaration and Assignment
Declaration means announcing the variable exists and allocating memory for it. Assignment means actually placing a value inside it. Some languages do both at once, while stricter languages require them to be separated.
Constants
Constants are like variables, but their value is locked upon creation and cannot change while the program runs. They are usually declared at the top of a program and named with uppercase letters to make them stand out.
Variable Scope: Global vs Local
Scope determines where a variable is "visible" or accessible. A Local Variable is declared inside a subroutine (like a function) and is destroyed when that function ends. A Global Variable is declared in the main program and can be accessed by any code block.
Syntax Variations by Exam Board
Here is how you actually write out these concepts depending on the board you are testing under.
AQA Pseudocode Standard (8520)
AQA implies typing. You do not need to use DECLARE; simply assigning a value creates the variable. AQA strictly uses the left arrow <- for assignment.
OCR Pseudocode Standard
OCR is Python-like. It uses standard mathematical operators, implied typing, and specifically requires type-casting methods if you want to switch between types.
Cambridge (CIE 9618) Standard
CIE treats pseudocode like a strongly typed language. You must explicitly declare variables and their types before using them, and assignment utilizes the arrow operator.
IB (International Baccalaureate) Standard
The IB standard utilizes a distinct visual style. Variables are strictly written in ALL CAPS, while structural keywords are lowercase.
Conclusion
Understanding how to declare, type, and assign variables is non-negotiable for writing effective pseudocode. Incorrect assignment operators or forgotten type declarations are common points lost in examinations.
Always remember your specific board's rules: OCR uses =, while AQA and CIE use <-. CIE requires DECLARE var : TYPE, whereas others allow you to just assign the value straight away.
Ready to practice? Try our editor.
Give our pseudocode editor a go today for free - with a built-in compiler, tools to convert pseudocode to code, and project saving, PseudoEditor makes writing pseudocode easier than ever!
Start coding now