|
|
|
|
|
|
|
7. a. Write a void function that reads in data values of type int (heartRate) until a normal heart rate (between 60 and 80) is read or EOF occurs. The function has one parameter, named normal, that contains TRUE if a normal heart rate was read or FALSE if EOF occurred. (Assume that a data type Boolean has already been defined.) |
|
|
|
|
|
|
|
|
b. Write a statement that invokes your function. You may use the same variable name for the actual and formal parameters. |
|
|
|
|
|
|
|
|
8. Consider the following function definition. |
|
|
|
 |
|
|
|
|
void Rotate( /* inout */ int& firstValue,
/* inout */ int& secondValue,
/* inout */ int& thirdValue )
{
int temp;
temp = firstValue;
firstValue = secondValue;
secondValue = thirdValue;
thirdValue = temp;
} |
|
|
|
|
|
|
|
|
a. Add comments to the function that tell a reader what the function does and what is the purpose of each parameter and local variable. |
|
|
|
|
|
|
|
|
b. Write a program that reads three values into variables, echo-prints them, calls the Rotate function with the three variables as parameters, and then prints the parameters after the function returns. |
|
|
|
|
|
|
|
|
9. Modify the function in Exercise 8 to perform the same sort of operation on four values. Modify the program you wrote for part b of Exercise 8 to work with the new version of this function. |
|
|
|
|
|
|
|
|
10. Write a void function named CountUpper that counts the number of uppercase letters on one line of input. The function should return this number to the calling code in a parameter named upCount. |
|
|
|
|
|
|
|
|
11. Write a void function named AddTime that has three parameters: hours, minutes, and elapsedTime. elapsedTime is an integer number of minutes to be added to the starting time passed in through hours and minutes. The resulting new time is returned through hours and minutes. For example: |
|
|
|
|
|
|
|
|
12. Write a void function named GetNonBlank that returns the first nonblank character it encounters in the standard input stream. In your function, use the cin.get function to read each character. (This GetNonBlank function is just for practice. It's unnecessary because you could use the >> operator, which skips leading blanks, to accomplish the same result.) |
|
|
|
|
|
|
|
|
13. Write a void function named SkipToBlank that skips all characters in the standard input stream until a blank is encountered. In your function, use the |
|
|
|
|
|