< previous page page_92 next page >

Page 92
seven printed lines high and should appear all in a row. For example, if your initials are DOW, your program should print out
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
DDDDDDD       OOOOO     W       W
D      D     O     O    W       W
D       D  O        O   W       W
D       D  O        O   W   W   W
D       D  O        O   W  W W  W
D      D     O     O    W W   W W
DDDDDDD       OOOOO     WW     WW
Be sure to include appropriate comments in your program, choose meaningful identifiers, and use indentation as we do in the programs in this chapter.
2. Many (but not all) C++ systems provide a header file limits.h. This header file contains declarations of constants related to the specific compiler and machine on which you are working. Two of these constants are INT_MAX and INT_MIN, the largest and smallest int values for your particular computer. Write a program to print out the values of INT_MAX and INT_MIN. The output should identify which value is INT_MAX and which value is INT_MIN. Be sure to include appropriate comments in your program, and use indentation as we do in the programs in this chapter.
3. Write a program that outputs three lines, labeled as follows:
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
7 / 4 using integer division equals <result>
7 / 4 using floating point division equals <result>
7 modulo 4 equals <result>
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
where <result> stands for the result computed by your program. Use named constants for 7 and 4 everywhere in your program (including the output statements) to make the program easy to modify. Be sure to include appropriate comments in your program, choose meaningful identifiers, and use indentation as we do in the programs in this chapter.
Case Study Follow-Up
1. What is the advantage of using named constants instead of literal constants in the Mileage program?
2. How would you change the Mileage program to add a fifth gasoline fillup of 10.3 gallons? Assume that the starting and ending mileages remain the same.

 
< previous page page_92 next page >