A name given to some numeric constant, character constant, string constant or any other constants is known as Symbolic constant.
Preprocessor directive #define is used to define symbolic constant.
Rules for defining a symbolic constant
- Symbolic constant is defined at definition section in basic structure of c program.
- # must be the first character in the line.
- No space is allowed between # and define.
- A space is required between #define, symbolic constant name and its value.
- ; should not be placed at the end.
- Rules for symbolic constant name is same as variables. However, typically symbolic constant name are written in uppercase letters.
Advantages of using symbolic constant
- To modify later
- only one change will be enough.
- Understandability
- for same value of different constant.
- writing constant name is easier to understand than simply writing value only.