September 1998
Intermediate to advanced
848 pages
20h 13m
English
Sometimes you need to use a constant in a program. For example, you could give the circumference of a circle as this:
circumference = 3.14159 * diameter;
Here, the constant 3.14159 represents the world-famous constant pi (ρ). To use a constant, just type in the actual value, as in the example. However, there are good reasons to use a symbolic constant instead. That is, you could use a statement like the following and have the computer substitute in the actual value later:
circumference = pi * diameter;
Why is it better to use a symbolic constant? First, a name tells you more than a number does. Compare these two statements:
owed = 0.015 * housevalue; owed = taxrate * housevalue;
If you read through a long ...
Read now
Unlock full access