Starting Out with C++ from Control Structures to Objects 8th Edition Gaddis Test Bank 2024 scribd download full chapters
Starting Out with C++ from Control Structures to Objects 8th Edition Gaddis Test Bank 2024 scribd download full chapters
com
https://testbankdeal.com/product/starting-out-with-c-from-
control-structures-to-objects-8th-edition-gaddis-test-bank/
OR CLICK HERE
DOWNLOAD NOW
https://testbankdeal.com/product/starting-out-with-c-from-control-
structures-to-objects-8th-edition-gaddis-solutions-manual/
testbankdeal.com
https://testbankdeal.com/product/starting-out-with-c-from-control-
structures-to-objects-9th-edition-gaddis-solutions-manual/
testbankdeal.com
https://testbankdeal.com/product/starting-out-with-c-from-control-
structures-to-objects-7th-edition-gaddis-solutions-manual/
testbankdeal.com
https://testbankdeal.com/product/public-relations-strategies-and-
tactics-11th-edition-wilcox-test-bank/
testbankdeal.com
Principles of Learning and Behavior 7th Edition Domjan
Test Bank
https://testbankdeal.com/product/principles-of-learning-and-
behavior-7th-edition-domjan-test-bank/
testbankdeal.com
https://testbankdeal.com/product/introduction-to-general-organic-and-
biochemistry-10th-edition-bettelheim-test-bank/
testbankdeal.com
https://testbankdeal.com/product/organizational-behavior-10th-edition-
kreitner-solutions-manual/
testbankdeal.com
https://testbankdeal.com/product/foundations-of-business-4th-edition-
pride-test-bank/
testbankdeal.com
Principles of Microeconomics 6th Edition Frank Test Bank
https://testbankdeal.com/product/principles-of-microeconomics-6th-
edition-frank-test-bank/
testbankdeal.com
Starting Out with C++ from Control Structures to Objects, 8e (Gaddis)
Chapter 6 Functions
3) A function can have zero to many parameters, and it can return this many values.
A) zero to many
B) no
C) only one
D) a maximum of ten
E) None of these
Answer: C
1
Copyright © 2015 Pearson Education, Inc.
6) Functions are ideal for use in menu-driven programs. When a user selects a menu item, the program
can ________ the appropriate function.
A) call
B) prototype
C) define
D) declare
E) None of these
Answer: A
7) This type of variable is defined inside a function and is not accessible outside the function.
A) global
B) reference
C) local
D) counter
E) None of these
Answer: C
8) The value in this type of local variable persists between function calls.
A) global
B) internal
C) static
D) dynamic
E) None of these
Answer: C
9) These types of arguments are passed to parameters automatically if no argument is provided in the
function call.
A) Local
B) Default
C) Global
D) Relational
E) None of these
Answer: B
10) When used as parameters, these types of variables allow a function to access the parameter's original
argument.
A) reference
B) floating-point
C) counter
D) undeclared
E) None of these
Answer: A
2
Copyright © 2015 Pearson Education, Inc.
11) This statement causes a function to end.
A) end
B) terminate
C) return
D) release
E) None of these
Answer: C
12) ________ functions may have the same name, as long as their parameter lists are different.
A) Only two
B) Two or more
C) Zero
D) Un-prototyped
E) None of these
Answer: B
13) This function causes a program to terminate, regardless of which function or control mechanism is
executing.
A) terminate()
B) return()
C) continue()
D) exit()
E) None of these
Answer: D
3
Copyright © 2015 Pearson Education, Inc.
14) Given the following function definition:
c = a + 2;
a = a * 3;
b = c + a;
}
What is the output of the following code fragment that invokes calc?
int x = 1;
int y = 2;
int z = 3;
calc(x, y);
cout << x << " " << y << " " << z << endl;
A) 1 2 3
B) 1 6 3
C) 3 6 3
D) 1 14 9
E) None of these
Answer: B
Answer: D
16) It is a good programming practice to ________ your functions by writing comments that describe
what they do.
A) execute
B) document
C) eliminate
D) prototype
E) None of these
Answer: B
4
Copyright © 2015 Pearson Education, Inc.
17) A(n) ________ is information that is passed to a function, and a(n) ________ is information that is
received by a function.
A) function call, function header
B) parameter, argument
C) argument, parameter
D) prototype, header
E) None of these
Answer: C
19) A function ________ eliminates the need to place a function definition before all calls to the function.
A) header
B) prototype
C) argument
D) parameter
E) None of these
Answer: B
21) If a function is called more than once in a program, the values stored in the function's local variables
do not ________ between function calls.
A) persist
B) execute
C) communicate
D) change
E) None of these
Answer: A
5
Copyright © 2015 Pearson Education, Inc.
22) A ________ argument is passed to a parameter when the actual argument is left out of the function
call.
A) false
B) true
C) null
D) default
E) None of these
Answer: D
23) If a function does not have a prototype, default arguments may be specified in the function ________.
A) call
B) header
C) execution
D) return type
E) None of these
Answer: B
24) EXIT_FAILURE and ________ are named constants that may be used to indicate success or failure
when the exit() function is called.
A) EXIT_TERMINATE
B) EXIT_SUCCESS
C) EXIT_OK
D) RETURN_OK
E) None of these
Answer: B
26) This is a dummy function that is called instead of the actual function it represents.
A) main function
B) stub
C) driver
D) overloaded function
Answer: B
6
Copyright © 2015 Pearson Education, Inc.
27) What is the output of the following program?
#include <iostream>
using namespace std;
void showDub(int);
int main()
{
int x = 2;
showDub(x);
cout << x << endl;
return 0;
}
A) 2
2
B) 4
2
C) 2
4
D) 4
4
Answer: B
7
Copyright © 2015 Pearson Education, Inc.
28) What is the output of the following program?
#include <iostream>
using namespace std;
void doSomething(int);
int main()
{
int x = 2;
A) 2
0
2
B) 2
2
2
C) 0
0
0
D) 2
0
0
Answer: A
8
Copyright © 2015 Pearson Education, Inc.
29) What is the output of the following program?
#include <iostream>
using namespace std;
void doSomething(int&);
int main()
{
int x = 2;
A) 2
0
2
B) 2
2
2
C) 0
0
0
D) 2
0
0
Answer: D
9
Copyright © 2015 Pearson Education, Inc.
30) Which line in the following program contains the prototype for the showDub function?
1 #include <iostream>
2 using namespace std;
3
4 void showDub(int);
5
6 int main()
7 {
8 int x = 2;
9
10 showDub(x);
11 cout << x << endl;
12 return 0;
13 }
14
15 void showDub(int num)
16 {
17 cout << (num * 2) << endl;
18 }
A) 4
B) 6
C) 10
D) 15
Answer: A
10
Copyright © 2015 Pearson Education, Inc.
31) Which line in the following program contains the header for the showDub function?
1 #include <iostream>
2 using namespace std;
3
4 void showDub(int);
5
6 int main()
7 {
8 int x = 2;
9
10 showDub(x);
11 cout << x << endl;
12 return 0;
13 }
14
15 void showDub(int num)
16 {
17 cout << (num * 2) << endl;
18 }
A) 4
B) 6
C) 10
D) 15
Answer: D
11
Copyright © 2015 Pearson Education, Inc.
32) Which line in the following program contains a call to the showDub function?
1 #include <iostream>
2 using namespace std;
3
4 void showDub(int);
5
6 int main()
7 {
8 int x = 2;
9
10 showDub(x);
11 cout << x << endl;
12 return 0;
13 }
14
15 void showDub(int num)
16 {
17 cout << (num * 2) << endl;
18 }
A) 4
B) 6
C) 10
D) 15
Answer: C
int myFunction(double);
int myFunction(double);
12
Copyright © 2015 Pearson Education, Inc.
35) Look at the following function prototype.
#include <iostream>
using namespace std;
int getValue(int);
int main()
{
int x = 2;
A) 5
B) 2
C) 7
D) "getValue(x)"
Answer: C
13
Copyright © 2015 Pearson Education, Inc.
6.2 True/False Questions
1) True/False: When a function is called, flow of control moves to the function's prototype.
Answer: FALSE
3) True/False: A local variable and a global variable may not have the same name within the same
program.
Answer: FALSE
4) True/False: A static variable that is defined within a function is initialized only once, the first time the
function is called.
Answer: TRUE
5) True/False: It is possible for a function to have some parameters with default arguments and some
without.
Answer: TRUE
6) True/False: A function's return data type must be the same as the function's parameter(s).
Answer: FALSE
7) True/False: One reason for using functions is to break programs into manageable units, or modules.
Answer: TRUE
11) True/False: It is not considered good programming practice to declare all of your variables globally.
Answer: TRUE
12) True/False: You may use the exit() function to terminate a program, regardless of which control
mechanism is executing.
Answer: TRUE
14
Copyright © 2015 Pearson Education, Inc.
Another Random Document on
Scribd Without Any Related Topics
OR IMPLIED, INCLUDING BUT NOT LIMITED TO
WARRANTIES OF MERCHANTABILITY OR FITNESS FOR
ANY PURPOSE.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.