In the C programming language, what keyword defines a constant?

The story behind the answer

In the C programming language, the keyword that declares an object as read-only is const.

A declaration such as const int limit = 100; tells the compiler that the program should not modify limit through its declared type. The qualifier is part of the type system, so const helps the compiler detect accidental assignments and documents the programmer’s intent. It is especially useful for function parameters and pointers.

The meaning becomes more subtle with pointers. const int *p means p points to an integer that cannot be changed through p, while int *const p means the pointer itself cannot point elsewhere. A declaration can make both the pointer and the pointed-to value const.

const is not identical to a preprocessor macro such as #define. A macro is replaced before compilation and has no ordinary C type, whereas a const-qualified object participates in type checking and scope rules. The keyword was standardized in C89. The alternatives shown have different roles: extern declares linkage, static controls storage or linkage, and volatile concerns externally changing values.

Source: Wikipedia · fact-checked Aug. 2026

Add question to a list

Choose a list to keep this question in: