ADS

Symbolic Constant in C Programming | C Programming

Symbolic Constant in C Programming 

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 constant may then appear later in the program in a place of the numeric constants, character constants, etc, that the symbolic constants represents.

For Example:

C program consists of the following symbolic constant definitions.
#define PI 3.141593
#define TRUE1
#define FALSE0

#define PI 3.141593 defines a symbolic constant PI whose value is 3.141593


Program

#include<stdio.h>
#include<conio.h>
#define PI 3.141593
int main()
{
float r,a,c;
float   d=PI;
printf("Enter radius:");
scanf("%f",&r);
a=2*d*r*r;
c=2*d*r;
printf("The area of the circle is %f and the circumference of the circle is %f.",a,c);
return 0;
}


OUTPUT

Post a Comment

0 Comments