Definition
To introduce a variable by giving it an identifier and reserving space in memory, without assigning it a value.
Characteristics
- Establishes the variable’s identifier and (sometimes) its data type
- Separates identification from assignment in languages like C, C++, and Java
- Not required in all languages: in Python, variables never need to be introduced before they are initialised
Examples
- Declaring a variable of type
intin C:int x; - Declaring a variable in JavaScript:
let x;
Non-examples
- Initialising a variable:
x = 5 - Updating the value of a variable (C):
int x; // declaration
x = 5; // initialisation
x = 10; // assignment