Professional Documents
Culture Documents
Starting Out with C++ from Control Structures to Objects 8th Edition Gaddis Test Bank instant download all chapter
Starting Out with C++ from Control Structures to Objects 8th Edition Gaddis Test Bank instant download all chapter
https://testbankdeal.com/product/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-9th-edition-gaddis-solutions-
manual/
https://testbankdeal.com/product/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-through-objects-brief-version-8th-edition-
gaddis-test-bank/
Starting Out With C++ From Control Structures Through
Objects 7th Edition Tony Gaddis Test Bank
https://testbankdeal.com/product/starting-out-with-c-from-
control-structures-through-objects-7th-edition-tony-gaddis-test-
bank/
https://testbankdeal.com/product/starting-out-with-c-from-
control-structures-through-objects-brief-version-9th-edition-
gaddis-test-bank/
https://testbankdeal.com/product/starting-out-with-c-from-
control-structures-through-objects-brief-version-9th-edition-
gaddis-solutions-manual/
https://testbankdeal.com/product/starting-out-with-java-from-
control-structures-through-objects-6th-edition-gaddis-test-bank/
https://testbankdeal.com/product/starting-out-with-java-from-
control-structures-through-objects-7th-edition-gaddis-test-bank/
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 with
no related content on Scribd:
VESTGÖTHE:
Oot toden totta, sen nään, sä lemmen pauloissa. Mut ihme, kun
vasta nyt se kukkaan puhkeaa.
NIILO SKALM:
VESTGÖTHE:
Ahaa, jo arvaan: yksi niistä neidoista hän on, joit' eilen saapui
Puolasta ja tänne, kuulin, hovihimme jäävät.
NIILO SKALM:
Niin on, ja nimensä, sen kuulla sain vast' äsken myös, on Anna
Biehowska. Vain kerran näin ma hänet Vilnassa, mut siitä saakka
hänen kuvaansa oon sydämessäni mä säilytellyt. En
jälleennäkemistä osannut oo toivoa, mut hartain mielin ma
muistoansa olen palvonut ja kuvaans' yksikseni ihaellut. Nyt
varmaan ymmärtänet, kuinka äsken, kun ilmestyi hän tanssisaliin
tänne, mun valtas raju hämmästys ja riemu. Niin kiivaasti löi sydän
rinnassain kuin ulos syöstä ois se tahtonut, ja polvihini tuskin luottaa
saatoin.
VESTGÖTHE:
NIILO SKALM:
Mua muistavan? Niin luulen. Ei, ma olen varma siitä. Siks näin nyt
haltioissani mun näät. Ma siitä varmuutehen päästäkseni pois
muiden näkyvistä salaa hiivin ja käytöstänsä pidin silmällä. Hän
tanssin jälkeen äsken lepäs tässä, (osoittaa tuolia) kun tuolta
seinustalta takaa muiden mä häntä salaa katseillani ahmin. Hän
silmillänsä etsi jotakin ja lomitse kun tanssivaisten viimein hän keksi
minut tuolta ikkunalta, niin — ah, se katse! Kuinka tunkikaan se
sielun salaisihin syvyyksiin, ja uudet, oudon kummat sävelet sai
rinnassani värjyin helkkymään. Kuin kuumeessa mun hohti poskeni
ja vaivoin vain sain itsein hillityksi ma etten polvilleni etehensä täss'
syöksähtänyt koko hovin nähden.
VESTGÖTHE:
NIILO SKALM:
VESTGÖTHE:
NIILO SKALM:
Kuin oonkaan ma iloinen, ett' altis kuulemaan niin olet sydämeni
ääniä. Sa, rakas Klaus, mun paras ystäväni, vain sulle yksin suuret
asiani nyt tahdon uskoa. Siis kuule, veikko:
VESTGÖTHE:
Ei suinkaan. Mutta —
NIILO SKALM:
NIILO SKALM:
VESTGÖTHE:
NIILO SKALM:
Nyt toden totta en tiedä, itkeä vai nauraako mun tulis! Niinhän,
veikkoseni, haastat, kuin vanhat viisariamme, Horn ja Fleming, nuo,
jotka tuulten suuntaa nuuskimaan niin valppait' ovat, joille valtapaikat
— kun ilman vaaraa saa ne hankituksi — ja suuret tulot, oma
mukavuus on kaikki kaikessa. Jos viisaus on sellaista, en koskaan
viisahaksi ma tahdo tulla, jos taas vaikuttaa sen ikä, niin mun Herra
nuorena pois täältä korjatkoon! Jos vaimo, lapset sen saavat aikaan,
lempi rinnassain jo alkuhunsa sammukoon!
VESTGÖTHE:
NIILO SKALM:
Mut sinä, veli, et sama ole Klaus, jonk' opin vuotta noin
kymmenkunta sitten tuntemaan.
VESTGÖTHE:
Kuin niin?
NIILO SKALM:
VESTGÖTHE:
NIILO SKALM:
VESTGÖTHE:
Niin luulisin. Sa tiedät, isäni, hän Ruotsist' oli syntyisin, mut minä
maan tämän olen lapsi; nuoruusmuistot, ens lempi, ystävät — joist'
ensimmäinen oot sinä, Skalm — ne kaikki sitovat mun tähän
maahan. Leiriä jos kerran kaks muodostaisi Suomi sekä Ruotsi, mun
löytäisit sä leiriss' suomalaisten. Mut mi on syynä tähän tutkailuun?
Tääll' eihän tekeillä vain jotain lie?
NIILO SKALM:
Ei, ystäväni, siihen viittaavaa en hiirenhiiskausta kuullut ole. Näin
lumoihinsa tempas äsken vasta tää aate minutkin. Mut tunnetuksi ja
eläväks sen kaikkein mielissä täst' alkain täytyy tulla. Herttualle mun
ennen kaikkea —
VESTGÖTHE:
NIILO SKALM:
HERTTUA:
ANNA:
HERTTUA:
ANNA:
Minä vakuutan —
HERTTUA:
ANNA (syrjään):
ANNA:
Halua ei
tanssiin mulla
ole.
(Äänettömyys.)
GONSIESKY:
ANNA:
On hauska, ett' aiheesta niin vähäisestä riemuun voi sydämenne
riehahtaa.
GONSIESKY:
ANNA:
(Siirtyy vasemmalle.)
GONSIESKY (yksin):
(Poistuu oikealle.)
HERTTUA:
Vaihtakaamme
nyt tanssi keittotaidon tutkintaan!
(Soittajille)
Te siellä, pöytämarssi soittakaa!
(Vieraille kumartaen)
Ma pyydän, jalo vallasväki!
ANNA:
Niin kyllä.
Mä kultasoljen hukanneeni huomaan.
NIILO SKALM:
ANNA:
Ah, todellako?
NIILO SKALM:
ANNA:
NIILO SKALM:
Sydämeni!
(Äänettömyys.)
Jo viime vuonna Vilnassa se sattui.
(Äänettömyys.)
Mun, armollinen neiti, muistatte
kai Vilnan turnajaisista?
Niin — muistan.
NIILO SKALM:
ANNA:
Ah!
Ne tallella siis teillä on!
NIILO SKALM:
Siis tietäkää: Sen jälkeen Vilnassa kun ensi kerran teidät kohtasin,
on rauha rinnastani poissa ollut. Ma sieluineni, ruumiineni olen siit'
alkain teille yksin kuulunut. Kuin jano polttava on yltynyt mun
rinnassani tuska rakkauden ja teitä huutanut on kaikki, kaikki, mi
elonherkkää, syttyväistä on mun nuoress' olemuksessain: siks tänne
yön, talven valtaa uhmaten mun täytyi pois kotimaasta rientää,
saadakseni vain kerran vielä teidät kohdata ja kuulla äänenne ja —
julistaa: ma teidän, teidän kaikkineni olen!
NIILO SKALM:
Pois
riennä, tuolt'
ääniä ma
kuulen!
ANNA:
Vielä kerran!
Ja vielä — vielä!
NIILO SKALM:
Äänen herttuan ma kuulen!
HERTTUA:
HORN:
HERTTUA (lähettiläille):
ROSENGREN:
HERTTUA:
No, siis asianne?
ROSENGREN:
BRUSER:
HERTTUA:
ROSENGREN:
HERTTUATAR:
ROSENGREN:
Selvä on
kuninkaan se
vaatimus.
HERTTUA:
Ja muuta teill'
onko varastossa
vaatimusta?
ROSENGREN:
On käynyt selville —
BRUSER:
On todisteita —
HERTTUA:
ROSENGREN:
HERTTUA:
Minkä kaiken?
Ja kuka?
ROSENGREN:
Johan Slang.
HERTTUA:
ROSENGREN:
BRUSER:
HERTTUA:
ROSENGREN:
HERTTUA:
HERTTUATAR:
HERTTUA:
Selvästi
ne verukkeit' on vain, mun kimppuuni
joill' Eerik päästä tahtoo.
(Fleming palaa.)
Tukholmaan
mun lähtemään nyt neuvotteko, Horn?
HORN:
HERTTUA:
Ja miksi sinne?
HORN:
HORN:
HERTTUA (keskeyttäen):
FLEMING:
HERTTUA:
HORN:
Pyydän —
HERTTUA: