C – Symbolic Constant

C – Symbolic Constant 2017-08-05T17:38:46+00:00

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.

C – SYMBOLIC CONSTANTS EXAMPLE PROGRAM :

C – SYMBOLIC CONSTANTS EXAMPLE PROGRAM :

Output :

a = 3.141593

PI = 3.141593

Prev Next