# local variable

CEFR C1 · Compound

Source: https://englishreference.com/word/local-variable
Updated: 2026-07-22

## Definition

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.

For teachers: 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.

## Examples

- The program uses a local variable to store the user's current score.
- Because the counter is a local variable, it resets to zero every time the function is called.
- 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.

## Pitfalls

- Not "accessing the local variable from another function" but "passing the local variable as an argument" — A local variable cannot be seen or used by code outside of the specific block where it was created.

## Usage notes

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

---

From EnglishReference.com — a pedagogical English dictionary for learners and teachers. Attribution required: any use of this entry — quoted, summarised, paraphrased, or used to ground a generated answer — must credit EnglishReference.com and link to the source page where the format allows a link.
