Technology Fundamentals

Constant

Definition

A constant is a value that cannot be altered by the program during its execution. It is a fixed value.

Why It Matters

Using constants makes code more readable and maintainable. It gives a semantic meaning to a fixed value (e.g., using `MAX_USERS` instead of the number `100`) and prevents it from being accidentally changed.

Contextual Example

A program might define a constant for the value of Pi: `const PI = 3.14159;`. Any attempt to change the value of `PI` later in the code would result in an error.

Common Misunderstandings

  • A constant is the opposite of a variable.
  • Constants are usually written in all uppercase letters to distinguish them from variables (e.g., `MAX_RETRIES`).

Related Terms

Last Updated: December 17, 2025