Exercise 9-6: Pass by Reference and Pass by Address In this exercise, you use what you have learned about passing arguments by reference and by address to functions to answer Questions 1-2. 1. Given the following variable and function declarations, write the function call and the function's header a. double price 22.95, increase .10; void changePrice(doubl e&, double); b. double price 22.95, increase .10; void changePrice (double*, double); c. int age = 23; void changeAge(int&); d. int age 23; void changeAge (int*); 2. Given the following function headers and variable declarations, write a function call: a. custNames [] = {"Perez", "Smith", "Patel", "Shaw"}; balances [] = {34.00, 21.00, 45.50, 67.00); void cust (string name [], double bal []) b. int values [] = {1, 77, 89, 321, -2, 34}: void printSum (int nums [])
Exercise 9-6: Pass by Reference and Pass by Address
In this exercise, you use what you have learned about passing arguments by reference and by
address to functions to answer Questions 1-2.
1. Given the following variable and function declarations, write the function call and
the function's header
a. double price 22.95, increase .10;
void changePrice(doubl e&, double);
b. double price 22.95, increase .10;
void changePrice (double*, double);
c. int age = 23;
void changeAge(int&);
d. int age 23;
void changeAge (int*);
2. Given the following function headers and variable declarations, write a function call:
a. custNames [] = {"Perez", "Smith", "Patel", "Shaw"};
balances [] = {34.00, 21.00, 45.50, 67.00);
void cust (string name [], double bal [])
b. int values [] = {1, 77, 89, 321, -2, 34}:
void printSum (int nums [])
Step by step
Solved in 2 steps