What are Symbolic Constant and its advantages in C Programming?
A Symbolic Constant is a name that substitutes for a sequence of characters. The characters may represent numeric constant, a character constant or a string constant. Thus, a symbolic constant allows a name to appear in place of a numeric constant, a character constant or a string.
Declaration of Symbolic Constant:
A symbolic constant is declared as follows:
#define symbolic_name value of constant
Valid examples of constant definitions are
#define STRENGTH 100
#define PASS_MARK 50
#define MAX 200
#define Pl 3.14159
Symbolic constants are sometimes called constant identifiers. Since the symbolic names are constants they do not appear in declarations. The following rules apply to the #define statement which defines a symbolic constant.
- Symbolic names have the same form as variable names. (Symbolic names are written in CAPITALS to visually distinguish them from the normal variable names which are written in lowercase letters. This is only a convention, not a rule.)
- No blank space between the pound sign and the word define is permitted.
- #define student must not end with a semicolon.
- A blank space is required between ^define and symbolic name and between the symbolic name and constant
- Symbolic names are not declared for data types.
Advantages of Symbolic Constant:
- It makes the programs easier to understand and readable.
- It makes the programs more powerful.
- It makes the program modification easier.
- Their use is recommended since, they contribute to the development of clear, orderly program.
For example, symbolic constants are more readily identified than the information that they represent, and the symbolic names usually suggest the significance of their associated data items.
Click Here: To Learn about token in c programming
Hope you like this article! if you really like this article so you are requested to give us a small review by selecting above stars according to our website!
The post What are Symbolic Constant and its advantages in C Programming? appeared first on All In One Tuts.
This post first appeared on All In One Tuts | Tech Tutorials And Videos | Tech, please read the originial post: here