There are two simple ways in C to define constants:
1. Using #define preprocessor.
2. Using const keyword.
Following is the form to use #define preprocessor to define a constant:
#define identifier value
Following example explains it in detail:
When the above code is compiled and executed, it produces following result:
value of area: 113.04
You can use const prefix to declare constants with a specific type as follows:
const type variable = value;
Following example explains it in detail:
When the above code is compiled and executed, it produces following result:
value of area : 150
Note: - Always define constants in CAPITAL. (Good Programming Practise)