A constant is a variable whose value cannot be changed after its definition. Constants in C are the fixed values and its value remains unchanged during the entire execution of the program. Generally, we use const
keyword to create a constant.
const double PI = 3.14;
There are two Ways in C to define constants
- Using const keyword.
- Using #define preprocessor.
- Constants are also called literals.
- Constants can be any of the data types.
- We can also define a constant using the
#define
preprocessor directive.