100% found this document useful (9 votes)
123 views

Starting Out with C++ from Control Structures to Objects 8th Edition Gaddis Test Bank 2024 scribd download full chapters

Out

Uploaded by

detekymedza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (9 votes)
123 views

Starting Out with C++ from Control Structures to Objects 8th Edition Gaddis Test Bank 2024 scribd download full chapters

Out

Uploaded by

detekymedza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Full download solution manual or testbank at testbankdeal.

com

Starting Out with C++ from Control Structures to


Objects 8th Edition Gaddis Test Bank

https://testbankdeal.com/product/starting-out-with-c-from-
control-structures-to-objects-8th-edition-gaddis-test-bank/

OR CLICK HERE

DOWNLOAD NOW

Download more solution manual or test bank from https://testbankdeal.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Starting Out with C++ from Control Structures to Objects


8th Edition Gaddis Solutions Manual

https://testbankdeal.com/product/starting-out-with-c-from-control-
structures-to-objects-8th-edition-gaddis-solutions-manual/

testbankdeal.com

Starting Out With C++ From Control Structures To Objects


9th Edition Gaddis Solutions Manual

https://testbankdeal.com/product/starting-out-with-c-from-control-
structures-to-objects-9th-edition-gaddis-solutions-manual/

testbankdeal.com

Starting Out With C++ From Control Structures To Objects


7th Edition Gaddis Solutions Manual

https://testbankdeal.com/product/starting-out-with-c-from-control-
structures-to-objects-7th-edition-gaddis-solutions-manual/

testbankdeal.com

Public Relations Strategies and Tactics 11th Edition


Wilcox Test Bank

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

South Western Federal Taxation 2019 Essentials of Taxation


Individuals and Business Entities 22nd Edition Raabe Test
Bank
https://testbankdeal.com/product/south-western-federal-
taxation-2019-essentials-of-taxation-individuals-and-business-
entities-22nd-edition-raabe-test-bank/
testbankdeal.com

Introduction to General Organic and Biochemistry 10th


Edition Bettelheim Test Bank

https://testbankdeal.com/product/introduction-to-general-organic-and-
biochemistry-10th-edition-bettelheim-test-bank/

testbankdeal.com

Organizational Behavior 10th Edition Kreitner Solutions


Manual

https://testbankdeal.com/product/organizational-behavior-10th-edition-
kreitner-solutions-manual/

testbankdeal.com

Foundations of Business 4th Edition Pride Test Bank

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

6.1 Multiple Choice Questions

1) This is a collection of statements that performs a specific task.


A) infinite loop
B) variable
C) constant
D) function
E) None of these
Answer: D

2) A function ________ contains the statements that make up the function.


A) definition
B) prototype
C) call
D) expression
E) parameter list
Answer: A

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

4) A function is executed when it is:


A) defined
B) prototyped
C) declared
D) called
E) None of these
Answer: D

5) In a function header, you must furnish:


A) data type(s) of the parameters
B) data type of the return value
C) the name of function
D) names of parameter variables
E) All of these
Answer: E

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:

void calc (int a, int& b)


{
int c;

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

15) This is a statement that causes a function to execute.


A) for loop
B) do-while loop
C) function prototype
D) function call
E) None of these

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

18) Which of the following statements about global variables is true?


A) A global variable is accessible only to the main function.
B) A global variable is declared in the highest-level block in which it is used.
C) A global variable can have the same name as a variable that is declared locally within a function.
D) If a function contains a local variable with the same name as a global variable, the global variable's
name takes precedence within the function.
E) All of these are true.
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

20) A ________ variable is declared outside all functions.


A) local
B) global
C) floating-point
D) counter
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

25) The value in a ________ variable persists between function calls.


A) dynamic
B) local
C) counter
D) static local
Answer: D

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;
}

void showDub(int num)


{
cout << (num * 2) << endl;
}

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;

cout << x << endl;


doSomething(x);
cout << x << endl;
return 0;
}

void doSomething(int num)


{
num = 0;
cout << num << endl;
}

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;

cout << x << endl;


doSomething(x);
cout << x << endl;
return 0;
}

void doSomething(int& num)


{
num = 0;
cout << num << endl;
}

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

33) Look at the following function prototype.

int myFunction(double);

What is the data type of the function's parameter variable?


A) int
B) double
C) void
D) Can't tell from the prototype
Answer: B

34) Look at the following function prototype.

int myFunction(double);

What is the data type of the function's return value?


A) int
B) double
C) void
D) Can't tell from the prototype
Answer: A

12
Copyright © 2015 Pearson Education, Inc.
35) Look at the following function prototype.

int myFunction(double, double, double);

How many parameter variables does this function have?


A) 1
B) 2
C) 3
D) Can't tell from the prototype
Answer: C

36) What is the output of the following program?

#include <iostream>
using namespace std;

int getValue(int);

int main()
{
int x = 2;

cout << getValue(x) << endl;


return 0;
}

int getValue(int num)


{
return num + 5;
}

A) 5
B) 2
C) 7
D) "getValue(x)"
Answer: C

37) Here is the header for a function named computeValue:

void computeValue(int value)

Which of the following is a valid call to the function?


A) computeValue(10)
B) computeValue(10);
C) void computeValue(10);
D) void computeValue(int x);
Answer: B

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

2) True/False: A parameter is a special-purpose variable that is declared inside the parentheses of a


function definition.
Answer: TRUE

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

8) True/False: You must furnish an argument with a function call.


Answer: FALSE

9) True/False: Global variables are initialized to zero by default.


Answer: TRUE

10) True/False: Local variables are initialized to zero by default.


Answer: FALSE

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.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of
damages. If any disclaimer or limitation set forth in this
agreement violates the law of the state applicable to this
agreement, the agreement shall be interpreted to make the
maximum disclaimer or limitation permitted by the applicable
state law. The invalidity or unenforceability of any provision of
this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the


Foundation, the trademark owner, any agent or employee of the
Foundation, anyone providing copies of Project Gutenberg™
electronic works in accordance with this agreement, and any
volunteers associated with the production, promotion and
distribution of Project Gutenberg™ electronic works, harmless
from all liability, costs and expenses, including legal fees, that
arise directly or indirectly from any of the following which you do
or cause to occur: (a) distribution of this or any Project
Gutenberg™ work, (b) alteration, modification, or additions or
deletions to any Project Gutenberg™ work, and (c) any Defect
you cause.

Section 2. Information about the Mission of


Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new
computers. It exists because of the efforts of hundreds of
volunteers and donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project
Gutenberg™’s goals and ensuring that the Project Gutenberg™
collection will remain freely available for generations to come. In
2001, the Project Gutenberg Literary Archive Foundation was
created to provide a secure and permanent future for Project
Gutenberg™ and future generations. To learn more about the
Project Gutenberg Literary Archive Foundation and how your
efforts and donations can help, see Sections 3 and 4 and the
Foundation information page at www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-
profit 501(c)(3) educational corporation organized under the
laws of the state of Mississippi and granted tax exempt status by
the Internal Revenue Service. The Foundation’s EIN or federal
tax identification number is 64-6221541. Contributions to the
Project Gutenberg Literary Archive Foundation are tax
deductible to the full extent permitted by U.S. federal laws and
your state’s laws.

The Foundation’s business office is located at 809 North 1500


West, Salt Lake City, UT 84116, (801) 596-1887. Email contact
links and up to date contact information can be found at the
Foundation’s website and official page at
www.gutenberg.org/contact

Section 4. Information about Donations to


the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission
of increasing the number of public domain and licensed works
that can be freely distributed in machine-readable form
accessible by the widest array of equipment including outdated
equipment. Many small donations ($1 to $5,000) are particularly
important to maintaining tax exempt status with the IRS.

The Foundation is committed to complying with the laws


regulating charities and charitable donations in all 50 states of
the United States. Compliance requirements are not uniform
and it takes a considerable effort, much paperwork and many
fees to meet and keep up with these requirements. We do not
solicit donations in locations where we have not received written
confirmation of compliance. To SEND DONATIONS or
determine the status of compliance for any particular state visit
www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states


where we have not met the solicitation requirements, we know
of no prohibition against accepting unsolicited donations from
donors in such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot


make any statements concerning tax treatment of donations
received from outside the United States. U.S. laws alone swamp
our small staff.

Please check the Project Gutenberg web pages for current


donation methods and addresses. Donations are accepted in a
number of other ways including checks, online payments and
credit card donations. To donate, please visit:
www.gutenberg.org/donate.

Section 5. General Information About Project


Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could
be freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose
network of volunteer support.

Project Gutenberg™ eBooks are often created from several


printed editions, all of which are confirmed as not protected by
copyright in the U.S. unless a copyright notice is included. Thus,
we do not necessarily keep eBooks in compliance with any
particular paper edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg
Literary Archive Foundation, how to help produce our new
eBooks, and how to subscribe to our email newsletter to hear
about new eBooks.

You might also like