The C++ Programming Language 663
BD2
Quiz ..............................................................................................................
- What C++ object is available for printing?
- When should you use printf()in a C++ program?
- What values can be stored in the booldata type?
- What is the difference between declaring variables in C++ versus C?
- What operator(s) are available in C++ that are not available in C?
- What is the difference between using default values and using function overload-
ing? - Which of the following function declarations can be overlaid with each other?
int triangle( int angle, int side1, int side2);
int triangle(int side1, int side2, int side 3);
int triangle(int side1, int side 2, int angle); - Declare a function called triangle that receives three parameters:side1,side2, and
side3. Each of these should be of type int. Set each of the sides to have a default
value of 0. - True or False: An inline function is a function that is replicated into the code
within a listing.
Exercises ........................................................................................................
- Write a program that calculates the area of a box. Allow the user to enter the
height, width, and length of the box. - Modify the program in exercise 1 to calculate the cost of shipping the box. Assume
that the cost is based solely on the number of cubic units of the box. If the box is
under 100 cubic units, the cost is $5. If it is over 100 and less than 1000 units, it is
$10. If it is over 1000 units, it is $20. Create the function to use a default value of
$20. - Specify the function that calculates the area of the box to be inline.
37 448201x-Bonus2 8/13/02 11:18 AM Page 663