C Programming Language

Symbolic constant in c Language

                    A symbolic constant is name that substitute for a sequence of character that cannot be changed. The character may represent a numeric constant, a character constant, or a string. When the program is compiled, each occurrence of a symbolic constant is replaced by its corresponding character sequence. They are usually defined at the beginning of the program. The symbolic constants may then appear later in the program in place of the numeric constants, character constants, etc., that the symbolic constants represent.

For example

, a C program consists of the following symbolic constant definitions.
#define PI 3.141593
#define TRUE 1
#define FALSE 0

#define PI 3.141593 defines a symbolic constant PI whose value is 3.141593. When the program is preprocessed, all occurrences of the symbolic constant PI are replaced with the replacement text 3.141593.

Note that the preprocessor statements begin with a #symbol, and are not end with a semicolon. By convention, preprocessor constants are written in UPPERCASE.

Example: 1

#define TRUE 1
#define PI 3.141593

void main()

    float     a;
    float     b;
    float     c;
    float   d=PI;  

Example: 2

Symbolic constant in c programming Language | C Programming Expert.com | The Easy way to learn c programming language | Let's learn in different way
Statements Home Operators
c program stats