![]() |
![]() |
![]() |
![]() |
![]() |
|
Still another virtue of procedure abstraction is that you easily can
augment repetitive computations. For example, you have seen
doubling_time defined this way:
double doubling_time (double r) {
return 72.0 / r; }
You can easily decide to add a line to
doubling_time that displays the doubling time:
double doubling_time (double r) {
printf ("The doubling time for rate %f is approximately %f years.\n",
r, 72.0 / r);
return 72.0 / r;
}
Thus, to arrange for display, you do not need even to bother to find all
the places where a doubling time is computed; you need only to change the
doubling_time function's definition.