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

Definitions by

The definition of Constant on this page is an original definition. If you would like to reference this page or cite this definition, you can use the green citation links above.

The goal of is to explain computer terminology in a way that is easy to understand. We strive for simplicity and accuracy with every definition we publish. If you have feedback about the Constant definition or would like to suggest a new technical term, please contact us.

Want to learn more tech terms? Subscribe to the daily or weekly newsletter and get featured terms and quizzes delivered to your inbox.

Sign up for the free TechTerms Newsletter

How often would you like to receive an email?

You can unsubscribe or change your frequency setting at any time using the links available in each email.

Questions? Please contact us.