September 1998
Intermediate to advanced
848 pages
20h 13m
English
Listing 5.16 is a useful program (if you're a runner or know one) that illustrates several of the ideas in this chapter. It looks long, but all the calculations are done in six lines near the end. The bulk of the program relays information between the computer and the user. We've tried using enough comments to make it nearly self-explanatory. Read through it, and when you are done, we'll clear up a few points.
/* running.c -- A useful program for runners */ #include <stdio.h> #define S_PER_M 60 /* seconds in a minute */ #define S_PER_H 3600 /* seconds in an hour */ #define M_PER_K 0.62137 /* miles in a kilometer */ int main(void) { double distk, distm; /* distance run in km and in miles */ ... |
Read now
Unlock full access