|
|
|
|
|
|
|
cout << setw(3) << storeNum << ;
PrintBarGraph(deptSales);
cout << endl;
} |
|
|
|
|
|
|
|
|
Chapter 8
Exam Preparation Exercises |
|
|
|
|
|
|
|
|
11. It is risky to use a reference parameter as a formal parameter of a valuereturning function because it provides a mechanism for side effects to escape from the function. A value-returning function usually is designed to return a single result (the function value), which is then used in the expression that called the function. If a value-returning function declares a reference parameter and modifies the parameter, that function is returning more than one result, which is not obvious from the way the function is invoked. (However, an I/O stream variable must be declared as a reference parameter, even in a valuereturning function.) |
|
|
|
|
|
|
|
|
Chapter 8
Programming Warm-Up Exercises |
|
|
|
|
|
|
|
|
3. Boolean NearlyEqual( /* in */ float num1,
/* in */ float num2,
/* in */ float difference )
5. float CompassHeading( /* in */ float trueCourse,
/* in */ float windCorrAngle,
/* in */ float variance,
/* in */ float deviation )
// Precondition:
// All parameters are assigned
// Postcondition:
// Function value == trueCourse + windCorrAngle +
// variance + deviation
{
return trueCourse + windCorrAngle + variance + deviation;
} |
|
|
|
|
|
|
|
|
8. Function body for Hypotenuse function (assuming the header file math.h has been included in order to access the sqrt function): |
|
|
|
|
|