Answer:
void calculate Weight(int height, bool personIsMale, int &result) {
if (personIsMale) {
result = 106 + (height - 60) * 6;
} else {
result = 100 + (height - 60) * 5;
}
}
- This function definition uses a pass-by-reference approach to calculate the ideal body weight of an average adult based on their height (given in inches) and gender (boolean).
- It takes three parameters: the height, a boolean representing the person's gender, and a reference variable to store the result.
- If the person is male, it calculates the ideal weight according to the formula of 106 plus 6 pounds for every inch over five feet.
- If the person is female, it calculates the ideal weight according to the formula of 100 plus 5 pounds for every inch over five feet.
- After the calculation, the result is stored in the reference variable.