Constants, as the name implies, never change their value which makes development changes easy and eliminates the use of “magic numbers”.
Syntax
There are two ways to declare a constant:
#define identifierName value
const type identifierName value;
identifierName is the constant, while the value is the literal.#define, you declare a text substitution label, which means that each instance of identifierName will be replaced with value by the preprocessor unless identifierName is inside a string.#define is never terminated with a ';', unless you want that semicolon to be part of the substitution.const keyword. While this is inefficient for normal constants, it is a good way to save lookup tables in Flash memory for example.