Symbolic constant
Defining Symbolic constant:
A symbolic constant value can be defined as a preprocessor statement that is used in the program as any other constant value.When you include the header file with the help of the keyword define, the constant is declared it is called symbolic constant.
Define symbolic constant:
#define symbolic_name value of constant
The symbolic name of variable or constant then after giving space put the value which wants to put.
Other examples:
#define PI 3.141593
#define TOTAL 100
You can also use this in as a global variable
PI-Symbolic constant 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
Symbolic constant in C program:
#define PI 3.141593
#define TRUE 1
#define FALSE 0
Symbolic constants are the constants represented by symbols...
Constants are values that don't change throughout the program execution
Example:
#include<stdio.h> #include<conio.h> #define NUM 15 //symbolic constant void main() { int a=NUM; printf("The constant is %d",a); getch(); }
Here #define is a preprocessor that will replace all the entries name NUM as 15. So, that the compiler works with the constant 15.
Comments
Post a Comment