20.7k views
3 votes
Assume a program contains a void function named calcNewPrice(). The function receives two double variables named oldPrice and newPrice. The function multiplies the contents of the oldPrice variable by 1.1, then stores the result in the newPrice variable. Which of the following can be used to call the calcNewPrice() function?(A) calcNewPrice(double oldPrice, double newPrice);(B) calcNewPrice(&oldPrice, newPrice);(C) calcNewPrice(oldPrice, &newPrice);(D) calcNewPrice(oldPrice, newPrice);

User EnigmaRM
by
3.4k points

1 Answer

1 vote

Answer:

(C) calcNewPrice(oldPrice, &newPrice);

Step-by-step explanation:

It's a void function so there's no return value, however they wanted to change a value. The only way to do that is to pass in an address of the variable into the function, and deference it and store the new data there.

User Jeremy Rodi
by
3.1k points