Using and Defining Functions
Which of the following statements calls the calcEndingInventory() above?
calcEndingInventory(beginInventory, sales, purchases, endingInventory)
Which of the following can be used to call the calcNewPrice() function in the question above?
calcNewPrice(oldPrice, newPrice);
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, based on the beginning inventory, sales, and purchase amounts passed to the function. The function should store the result in the endingInventory memory location. Which of the following function headers is correct?
void calcEndingInventory(int b, int a, int p, int &e)
A program contains a void function named calcNewPrice(). The function receives two double variables named oldPrice and newPrice provided in this order. The function multiplies the contents of the oldPrice variable by 1.1, then stores the result in the newPrice variable. Which of the following is the best function prototype for this function?
void calcNewPrice(double, double &);
Consider the following function scramble(): void scramble(int i, int &j, int k) { i = 10; j = 20; k = 30; } #include <iostream> using namespace std; int main() { int i = 1; int j = 2; int k = 3; scramble(j, j, j); cout << "i = " << i << " j = " << j << " k = " << k; return 0; }
i = 1 j = 20 k = 3
Consider the following function scramble(): void scramble(int i, int &j, int k) { i = 10; j = 20; k = 30; } What is the output of the following program fragment? #include <iostream> using namespace std; int main() { int i = 1; int j = 2; int k = 3; scramble(i, j, k); cout << "i = " << i << " j = " << j << " k = " << k; return 0; }
i = 1 j = 20 k = 3
Consider the following function scramble(): void scramble(int &i, int &j, int &k) { i = 10; j = 20; k = 30; } What is the output of the following program fragment? #include <iostream> using namespace std; int main() { int i = 1; int j = 2; int k = 3; scramble(j, j, j); cout << "i = " << i << " j = " << j << " k = " << k; return 0; }
i = 1 j = 30 k = 3
Consider the following function scramble(): void scramble(int i, int &j, int &k) { i = 10; j = 20; k = 30; } What is the output of the following program fragment? #include <iostream> using namespace std; int main() { int i = 1; int j = 2; int k = 3; scramble(j, j, j); cout << "i = " << i << " j = " << j << " k = " << k; return 0; }
i = 1 j = 30 k = 3
Consider the following function scramble(): void scramble(int &i, int &j, int &k) { i = 10; j = 20; k = 30; } What is the output of the following program fragment? #include <iostream> using namespace std; int main() { int i = 1; int j = 2; int k = 3; scramble(k, j, i); cout << "i = " << i << " j = " << j << " k = " << k; return 0; }
i = 30 j = 20 k = 10
Consider the following function scramble(): void scramble(int i, int &j, int &k) { i = 10; j = 20; k = 30; } What is the output of the following program fragment? #include <iostream> using namespace std; int main() { int i = 1; int j = 2; int k = 3; scramble(k, j, i); cout << "i = " << i << " j = " << j << " k = " << k; return 0; }
i = 30 j = 20 k = 3