Answers to Chapter 3 Review Questions ------------------------------------- 4. x++; 7. for (i = 15; i <= 25; i++) 8. total must be initialized to some explicit value before the statement "total += value;" is executed for the first time. Remember that a variable declaration by itself (i.e., "int total;") doesn't give the variable a meaningful value. "total += value;" is equivalent to "total = total + value;", which assumes that total already has been initialized to something. On the other hand, it is not necessary to initialize value because the first statement involving value is "value = GetInteger();", which doesn't assume anything about its current value. 14. The format code %.2f causes floating-point values to always be printed with two decimal places after the period, which is the standard way of writing monetary values expressed in dollars and cents. 15. printf("%-20.20s", name); 16. printf("%.3f", distance); 18. Using a single symbolic constant name (defined with #define) in place of the actual value of the constant makes changing your program later much easier, especially if the constant appears in many places throughout your code. Instead of going through your code, finding all the places where the constant appears, and changing all of these to a new value, all you need to do is change the value assigned to the symbolic name in the #define line. 19. #define Pi 3.14159 20. If BouncedCheckFee were an integer, the statement printf("This check bounces. $%.2f fee deducted.\n", BouncedCheckFee); would no longer work because it uses a %.2f format code, which is incompatible with an integer constant. To eliminate this restriction, you can explicitly turn BouncedCheckFee into a floating-point value by using a type cast operator: printf(" . . . ", (double) BouncedCheckFee); 22. Other programmers who need to understand how your program works. (Or, for that matter, you yourself---several weeks or months or years after having written the code!)