# Constant

In mathematics, a constant is a specific number or a symbol that is assigned a fixed value. For example, in the equation below, "y" and "x" are variables, while the numbers 2 and 3 are constants.

y = 2x - 3

Constants are also used in computer programming to store fixed values. They are typically declared at the top of a source code file or at the beginning of a function. Constants are useful for defining values that are used many times within a function or program. For example, in the C++ code below, min and max are declared as constants.

const int min = 10;
const int max = 100;

By using constants, programmers can modify multiple instances of a value at one time. For example, changing the value assigned to max in the example above will modify the value wherever max is referenced. If the number 100 was used instead of max, the programmer would have to modify each instance of "100" individually. Therefore, it is considered good programming practice to use constants whenever a fixed value is used multiple times.

Updated: May 3, 2012

Cite this definition:

https://techterms.com/definition/constant

#### TechTerms - The Tech Terms Computer Dictionary

This page contains a technical definition of Constant. It explains in computing terminology what Constant means and is one of many technical terms in the TechTerms dictionary.

All definitions on the TechTerms website are written to be technically accurate but also easy to understand. If you find this Constant definition to be helpful, you can reference it using the citation links above. If you think a term should be updated or added to the TechTerms dictionary, please email TechTerms!