Home

variables

Variables are symbols that represent quantities or data values. In mathematics, a variable denotes a value that can change, such as x in an equation. In computing, a variable is a name associated with a storage location that holds a value during program execution.

In programming languages, a variable combines a name, a storage location, and a value. The value can

Scope determines where a variable can be accessed: local variables are visible only within a block or

Initialization is the process of giving a variable its first value. Some languages require it before use;

typically
be
read
and
replaced
through
assignment.
Variables
have
types
that
describe
the
kind
of
data
they
hold,
and
many
languages
distinguish
between
mutable
and
immutable
bindings.
function,
while
global
variables
are
accessible
throughout
a
program.
Lifetimes
describe
when
storage
is
allocated
and
released,
such
as
per
call
or
for
the
duration
of
a
program.
Most
languages
are
case
sensitive,
require
valid
identifiers,
and
follow
rules
about
starting
characters
and
allowed
symbols.
others
provide
defaults.
Constants
or
final
variables
may
be
defined
to
prevent
changes
after
initialization.
Common
pitfalls
include
using
uninitialized
variables,
shadowing
names
in
inner
scopes,
and
type
errors
when
values
are
assigned
to
incompatible
variables.