Using and Defining Functions

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

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


Set pelajaran terkait

Chemistry of life review before quiz 4

View Set

LSU BIOL 1202 (HRINCEVICH) CH. 27 HW

View Set

U.S. History Since 1877 -Quiz Questions

View Set

Psych 295 - FINAL (Test #1 Answers)

View Set

Infection Control Module 2: Chain of Infection

View Set

late 1730s - mid-1740s THE GREAT AWAKENING.

View Set

Chapter 11 Measuring the cost of living

View Set

Concept 39 Professional Identity

View Set

market equilibrium, demand , and supply

View Set

9/12/17 AP US History Content Quiz Possible Questions List

View Set