September 2001
Beginner
970 pages
23h 20m
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> const int S_PER_M = 60; // seconds in a minute const int S_PER_H = 3600; // seconds in an hour const int 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