Using Symbolic constants(#define) While developing a program in C language,we often use certain unique constants in a program.These const. may appear repeatedly in a C program,at number of places. Foe example,if we want to calculate the area of n number of circles,we require a constant 3.14 which is the value of'pi'. Now we may like to change the value of pi from 3.14 to 3.14159.To achieve this we will have to search through-out the program and explicitly change the value of pi whereever it has been used.If any value is left unchanged the program will produce wrong results.When we use variable ,value may change accidently,which results to wrong output. To avoid these type of mistakes w use symbolic constants in our C program. the syntax of a symbolic constant is; #define symbolic name value e.g. #define pi 3.14159 #define total 100
C tutorials for Beginners. Learn C programming, easy and fast way. C language Projects.