Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A function call for a void function named calcEndingInventory() is passed four i

ID: 3812050 • Letter: A

Question

A function call for a void function named calcEndingInventory() is passed four int variables named beginInventory, sales, purchases, and endingInventory. The function’s task is to calculate the ending inventory, using the beginning inventory, sales, and purchase amounts passed to the function. The function should store the result in the endingInventoryvariable. Which of the following statements calls this function as described above?

a. calcEndingInventory(beginInventory, sales, purchases, endingInventory);

b. calcEndingInventory(int, int, int, int);

c. calcEndingInventory(beginInventory, sales, purchases, &endingInventory);

Explanation / Answer

Answer: c.

Since the function is a void function, it does not return any value.

To store or change the value of a variable in a void function, the variable must be passed a pointer.

Thus, in the function call,

calcEndingInventory(beginInventory, sales, purchases, &endingInventory);

the variable endingInventory is passed as a pointer so that the result could be stored in it in void function.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote