In
computer programming, a
constant is an
identifier with an associated
value which cannot be altered by the
program during normal execution – the value is
constant. This is contrasted with a
variable, which is an identifier with a value that can be changed during normal execution – the value is
variable. Constants are useful for both programmers and compilers: for programmers they are a form of
self-documenting code and allow reasoning about
correctness; while for compilers they allow
compile-time and
run-time checks that constancy assumptions are not violated, and allow or simplify some
compiler optimizations.