C provides a safer means of declaring named constants, other than by using the preprocessor. This is done by adding the constkeyword to a variable declaration. This sort of declaration must be of the const type identifier = value;form, where type, identifier, and value are the same as in our preceding variable declaration form—except here, the initializing value is not optional. The constant variable loses its ability to change after the statement is evaluated. If we don't give it a value when we declare it, we cannotdo so later. Such a declaration without an initializing value is, therefore, useless.
When we declare a constant in this manner, it is named; it has a type and it has a value that does not change. So, our previous example becomes as follows:
const float kInchesPerFoot = 12.0;
const float kFeetPerYard = 3.0;
feet = inches / kInchesPerFoot;
yards = feet / kFeetPerYard;
This is considered safer because...