Symbolic constants are typically defined using the #define preprocessor directive in C and C++. Here's an example:
#define PI 3.14159
This defines a symbolic constant named PI with a value of 3.14159. Once defined, PI can be used throughout the program wherever the value of pi is needed. For example:
double radius = 5.0;
double circumference = 2 * PI * radius;
Here, PI is used in the calculation of the circumference of a circle with a radius of 5.0.
Symbolic constants are useful because they make the code easier to read and understand, and they also make it easier to change the value of a constant throughout a program. If the value of pi were to change, for example, it would be much easier to update a single #define statement than to find and replace every instance of 3.14159 in the program.