ENGLISH
REFERENCE

local variable

compound.
C1 Advanced Programming
Definition

compound. a piece of information in a computer program that only exists inside one specific part, like a single function. Once that part of the code finishes running, the information is forgotten.

compound. a variable declared within a specific block of code, such as a function or subroutine, which is only accessible within that scope. It is typically deallocated from memory once the execution of that block concludes.


SIMPLE

The program uses a local variable to store the user's current score.

CONTEXTUAL

Because the counter is a local variable, it resets to zero every time the function is called.

COMPLEX

Developers prefer using a local variable over a global one to prevent unintended side effects and ensure that data remains encapsulated within the relevant logic block.

Origin

A compound of the adjective local, derived from the Latin locus meaning place, and the noun variable, from the Latin variare. The term emerged as a standard distinction in early programming languages to differentiate scope from global counterparts.

Etymology adapted from Wiktionary, available under CC BY-SA 4.0.

Usage

Commonly used in the context of computer science and software engineering.

Pitfall

accessing the local variable from another functionpassing the local variable as an argumentA local variable cannot be seen or used by code outside of the specific block where it was created.

Related words

Last updated July 22, 2026