Symbolic Constant in C


The Symbolic constant is a name that substitute a numeric constant, a character constant or a string constant.

Assume that we are computing the Area of circle using the formula : Area = pi * r * r = 3.142* r * r.

In this formula the numeric constant is 3.142 can be replaced by symbolic constant name pi. Here we substitute pi for a numeric constant. During compile time pi is replaced by its value defined. 

Symbolic Constants are defined using preprocessor statement i.e #define.

Eg: #define PI 3.142

    #define Name "PI"

Generally a symbolic constant is written in Upper case letters. It is not a strict rule but it is a good programming practice.

Symbolic constants must be defined at the beginning of a program i.e before main() of a C program.