Test 1-09/24/2018
1. Answer the following questions:
1.1 Complete the following phrase:
"If a C++ project employs functions it is recommended that the following parts are present: the ____ the
function's call, and the function definition."
1.2. If the following is a function call, what are the identifiers between parenthesis called?:
x = computeAverage(y, z);
1.3. If x, y, z in the question above are integers, write what the prototype of the function computeAverage()
should be?
2. For the given code
#include <iostream>
using namespace std;
/*
...????
*/
void main ()
{
char gender;
int age;
double HR;
cout<<"Please input your age (end with 0):";
cin>>age;
while (age > 0)
{
cout<<"Please input your gender (M or F):";
cin>>gender;
if ((gender == 'M') || (gender == 'm'))
HR = 220 - age;
else
if ((gender == 'F') || (gender == 'f'))
HR = 206 - 0.88 * age;
cout<<"Your maximun normal heart rate is: "<<HR<<endl<<endl<<endl;
cout<<"Please input your age (end with 0):";
cin>>age;
}
}
Do the following:
2.1. Complete the general comments of this program (in short state what the program does, what the input and
output are)
2.2 Complete the program to validate the gender (it cannot be other than M, m, F, or f)
2.3. Change the program to use this function: double ComputeHR(int, char);//prototype
You have to figure out what the return value and the parameters mean.
Grading Scale:
Pb 1 (10+10+15) Pb 2(15, 15, 25) Format of Submission (10) Total: 100