Problem Solving with C++ 9th Edition Savitch Test Bank pdf download
Problem Solving with C++ 9th Edition Savitch Test Bank pdf download
https://testbankdeal.com/product/problem-solving-with-c-9th-
edition-savitch-test-bank/
https://testbankdeal.com/product/problem-solving-with-c-9th-edition-
savitch-solutions-manual/
testbankdeal.com
https://testbankdeal.com/product/problem-solving-with-c-10th-edition-
savitch-test-bank/
testbankdeal.com
https://testbankdeal.com/product/problem-solving-with-c-10th-edition-
savitch-solutions-manual/
testbankdeal.com
https://testbankdeal.com/product/mathematics-for-economics-and-
business-6th-edition-jacques-test-bank/
testbankdeal.com
Nutrition A Functional Approach Canadian 3rd Edition
Thompson Solutions Manual
https://testbankdeal.com/product/nutrition-a-functional-approach-
canadian-3rd-edition-thompson-solutions-manual/
testbankdeal.com
https://testbankdeal.com/product/organisational-behaviour-
australia-8th-edition-robbins-test-bank/
testbankdeal.com
https://testbankdeal.com/product/criminal-investigation-3rd-edition-
brandl-test-bank/
testbankdeal.com
https://testbankdeal.com/product/auditing-and-assurance-services-15th-
edition-arens-solutions-manual/
testbankdeal.com
https://testbankdeal.com/product/introduction-to-forensic-psychology-
research-and-application-4th-edition-bartol-test-bank/
testbankdeal.com
Math for Business and Finance An Algebraic Approach 1st
Edition Slater Solutions Manual
https://testbankdeal.com/product/math-for-business-and-finance-an-
algebraic-approach-1st-edition-slater-solutions-manual/
testbankdeal.com
Test Bank for Problem Solving with C++: The Object of Programming, 9/e
Chapter 7 Arrays
TRUE/FALSE
1. The indexed variables (members) of an array must be integers.
ANSWER: FALSE
2. The locations of the various indexed variables in an array can be spread out all
over the memory.
ANSWER: FALSE
3. The following array declaration is legal
double scores[]={0.1,0.2,0.3};
ANSWER: true
4. Arrays can be passed to functions.
ANSWER: TRUE
5. Arrays can be returned from a function.
ANSWER: FALSE
6. If a function is expecting a pass by reference parameter, you can pass an index
variable from an array of the same base type to that function.
ANSWER: TRUE
7. When you have a function that expects an array, it should also expect the size of
the array or the number of indexed variables with valid data.
ANSWER: TRUE
8. The following function declaration guarantees the values in the array argument
are not changed.
ANSWER: FALSE
9. The following function will work with any size integer array.
ANSWER: TRUE
10. If you use the const modifier in a function declaration, you do not include it in the
function definition.
ANSWER: FALSE
Short Answer
1. Write the code to declare a two dimension array of integers with 10 rows and 20
columns.
ANSWER: int array[10][20];
2. Write the code to declare an array of 10 doubles named list;
ANSWER: double list[10];
3. The modifier that guarantees that an array argument will not be changed is called
______.
ANSWER: const
4. How many indexed variables does the following array have?
int myArray[]={1,2,3,6,5,4,7,1,2};
ANSWER: 9
Test Bank for Problem Solving with C++: The Object of Programming, 9/e
Chapter 7 Arrays
d. Nothing.
ANSWER: D
3. Given an array named scores with 25 elements, what is the correct way to access
the 25th element?
a. scores+25
b. scores[24]
c. scores[25]
d. scores[last]
ANSWER: B
4. Why should you use a named constant for the size of an array?
a. Readability of code
b. Makes changes to the program easier
c. Helps reduce logic errors
d. All of the above
ANSWER: D
5. Given an array of integers of size 5, how does the computer know where the 3rd
indexed variable is located?
a. It adds 3 to the base address of the array
b. It adds space for 3 integers to the base address of the array
c. It remembers where all the indexed variables of the array are located.
d. None of the above
ANSWER: B
6. What is wrong with the following code fragment?
const int SIZE =5;
float scores[SIZE];
for(int i=0; i<=SIZE;i++)
{
cout << "Enter a score\n";
cin >> scores[i];
}
a. Array indexes start at 1 not 0
b. Arrays must be integers
c. Array indexes must be less than the size of the array
d. Should be cin >> scores[0];
ANSWER: C
7. Which of the following declare an array of 5 characters, and initializes them to
some known values?
a. char array[5]={'a','b','c','d','e'};
b. char array[4]={'a','b','c','d','e'};
c. char array[5]={''};
d. char array[]={'a','b','d','e'};
e. A and C
f. B and D
g. all of the above
ANSWER: E
Test Bank for Problem Solving with C++: The Object of Programming, 9/e
Chapter 7 Arrays
8. If you declare and initialize an integer array of size 10, but only list 5 values, what
values are stored in the remaining 5 indexed variables?
a. 0
b. garbage
c. 0.0
d. '0'
ANSWER: A
9. Arrays are always passed to a function using
a. pass by value
b. pass by reference
c. pass by array
d. you cannot pass arrays to a function
ANSWER: C
10. Give the following declarations, which of the following is a legal call to this
function?
int myFunction(int myValue);
int myArray[1000];
a. cout << myFunction(myArray);
b. cout << myFunction(myArray[0]);
c. myArray = myFunction(myArray);
d. myArray[1] = myFunction(myArray[0]);
e. A and B
f. A and C
g. B and D
ANSWER: G
11. Which of the following function declarations correctly expect an array as the first
argument?
a. void f1(int array, int size);
b. void f1(int& array, int size);
c. void f1(int array[100], int size);
d. void f1(float array[], int size);
e. All of the above
f. C and D
g. A and B
ANSWER: F
12. Which of the following function declarations correctly guarantee that the function
will not change any values in the array argument?
a. void f1(int array[], int size) const;
b. void f1(int array[], int size);
c. void f1(int &array, int size);
d. void f1(const int array[], int size);
e. void f1(int array[], const int size);
ANSWER: D
13. The following function definition has an error in it. What line is this error on?
Test Bank for Problem Solving with C++: The Object of Programming, 9/e
Chapter 7 Arrays
17. Given the following function definition, will repeated calls to the search function
for the same target find all occurrences of that target in the array?
int search(const int array[], int target, int numElements)
{
int index=0;
bool found=false;
for(index2=0;index2<4;index2++)
cout << array[index1][index2] << " ";
cout << endl;
}
a. 0 1 2 3
1234
2345
3456
b. 0 1 2 3
0123
0123
0123
c. 0 0 0 0
1111
2222
3333
d. 0 0 0 0
0123
0246
0369
ANSWER: A
24. Which of the following correctly declare an array that can hold up to 3 rows of 5
columns of doubles?
a. int array[3],[5];
b. int array[3][5];
c. float array[3][5];
d. float array[3,5];
ANSWER: C
25. Which of the following function declarations can be passed the following array?
char myArray[6][8];
a. void f1(char a[][], int sizeOfFirst);
b. void f1(char a[][8], int sizeOfFirst);
c. void f1(char& a, int sizeOfFirst);
d. void f1(char a[6][8], int sizeOfFirst);
e. B and D
f. A and D
ANSWER: E
26. A two dimension array can also be thought of as
a. a table
b. an array of arrays
c. a file
d. none of the above
e. A and C
f. A and B
ANSWER: F
Test Bank for Problem Solving with C++: The Object of Programming, 9/e
Chapter 7 Arrays
27. Which of the following will correctly assign all the values in one array to the
other array? (Assume both arrays are of the same type and have SIZE elements)
a. array1=array2;
b. array1[]=array2;
c. for(i=0;i<SIZE;i++)
array1[i]=array2[i];
d. for(i=0;i<SIZE;i++)
array1[]=array2[];
ANSWER: C
28. Which of the following will read values from the keyboard into the array?
(Assume the size of the array is SIZE).
a. cin >> array;
b. cin >> array[];
c. cin >> array[SIZE];
d. for(i=0;i<SIZE;i++)
cin >> array[i];
ANSWER: D
29. Which of the following correctly uses C++11’s range-based for statement to
iterate through every element of the array variable arr?
a. for (auto x : arr)
b. foreach (x in arr)
c. for (auto x; x < arr.length; x++)
d. for x in arr
ANSWER: A
30. What is the output of this code?
int arr[] = { 1, 2, 3};
for (int &element : arr)
element+=10;
for (int element : arr)
cout << element << endl;
a. 1 2 3
b. 11 12 13
ANSWER: B
31. What is the output of this code?
int arr[] = { 1, 2, 3};
for (int element : arr)
element+=10;
for (int element : arr)
cout << element << endl;
a. 1 2 3
b. 11 12 13
ANSWER: A
Another Random Scribd Document
with Unrelated Content
The Project Gutenberg eBook of
Peeps at Many Lands: Siam
This ebook is for the use of anyone anywhere in the United States
and most other parts of the world at no cost and with almost no
restrictions whatsoever. You may copy it, give it away or re-use it
under the terms of the Project Gutenberg License included with this
ebook or online at www.gutenberg.org. If you are not located in the
United States, you will have to check the laws of the country where
you are located before using this eBook.
Language: English
SIAM
A TYPICAL CANAL SCENE. Chapter II.
PEEPS AT MANY LANDS
SIAM
BY
LONDON
ADAM AND CHARLES BLACK
1908
TO
MY CHILD FRIEND,
SYBIL MARJORIE COOPER,
Bangkok, the present capital of Siam, has been called "the Venice of
the East," on account of its innumerable waterways. The whole place
is threaded with canals of every possible size and description. There
are canals that are like great broad thoroughfares, where huge boats
may be seen carrying to and fro rice, fruit, and other products of the
fields and orchards; and tiny little water-lanes, where the broad
fronds of the graceful coco-nut palm sweep down over the sluggish
stream, where green parrots scream at you from amongst green
branches, and ugly dark crocodiles lie asleep in the thick and sticky
mud.
Along the sides of the "streets" there are long lines of floating
houses in which the people live. Each house floats on a big raft,
made of separate bundles of bamboo. Thus, when the floating
foundation begins to rot, the bundles can be replaced one by one
without disturbing the people on the raft. The raft is loosely moored
to big wooden stakes, which are driven deep in the bed of the river,
so that the houses rise and fall with the tide. In front of the house
there is always a little platform or veranda, on which the people pass
most of their time, and where, if they pretend to keep a shop, they
display the goods which they wish to sell. It is on this platform that
all the members of the family take their bath. They dip a bucket or
can into the water, draw it up, and then pour the contents over their
heads.
When the occupant of one of these floating dwellings wishes to
move, he sends for no furniture van or cart; but he simply shifts his
house, his furniture, and his family all at the same time. If he be
fairly well-to-do, he hires a steam-launch, and the little vessel goes
puffing and screaming up or down the river or the canal, as the case
may be, dragging behind it the miniature Noah's ark, while on the
platform the little ones of the household are to be seen, bubbling
over with merriment at the novelty of their experience. If the owner
of the house be too poor to hire a steam-launch, he calls to his aid a
number of muscular friends and relatives, and then, with the aid of
great shovel-shaped paddles, they coax the home away to its new
locality.
Some of the people who live on the water do not inhabit floating
houses, but boats, and in these they can travel about from time to
time as fancy or business may direct. Many people spend the whole
of their lives on boats. They are born on a boat, reared on a boat,
get their education neglected on a boat, go a-courting on a boat, get
married on a boat, and never forsake the water till life is over and
they set out on that long mysterious journey, from which no boat or
carriage will ever bring them back. There is not much room in a
boat, but the inhabitants thereof seem perfectly contented with their
lot; in fact, the Siamese seem to be always and everywhere perfectly
happy and contented: they are one of the merriest and most
cheerful people upon the face of the earth.
The water population is quite complete in itself, and does not
depend upon those who dwell upon the land for any assistance
whatever. There are not only floating houses, but floating
restaurants, floating theatres, and even floating jails. The water
population has its own market-place upon the broad bosom of the
great river that sweeps through the centre of the capital. In the
market the buyers and sellers are chiefly women, for the women are
much cleverer and much more energetic than men. The market
begins soon after midnight, and lasts till seven or eight in the
morning. During the dark hours of the night the boats are massed
together in such a way that scarcely an inch of water can be seen.
They are laden with fish, eggs, rice, and fruit. Each boat has a little
lamp at the prow, and in the soft yellow light that twinkles above the
polished surface of the stream, you can catch glimpses of the black-
haired, dark-skinned women busy with the vending of their
merchandise, and all the time laughing and chattering with the glee
of a carefree people. They are just like a party of merry children out
on a big picnic. As soon as the sun rises, off home they go, leaving a
broad and empty expanse of river where formerly there was a dense
crowd of little boats and busy women.
Siam has only one great river that is entirely her own. It is marked
on English maps as the "Menam," but its real name is the "Menam
Chow Phya." The word "Menam" is made up of two words, maa and
nam, and means the "mother of the waters." It is the name of every
river and stream in the country, and corresponds to our word "river."
The Menam is not merely the mother of the waters, but of the land
also, for all the lower part of Siam is one extensive plain, which has
been built up by the mud, gravel, and sand brought down from the
mountains by the river.
Suppose we get on board a steamer and sail from Bangkok down to
the mouth of the Menam. The distance from Bangkok to the mouth
of the river, measured as the crow flies, is only twelve miles, but so
much does the river twist and turn that we shall be three hours
before we reach the sea. But there is much to be seen in those three
hours, and the time passes away merrily enough.
THE GULF OF SIAM—MOONLIGHT. Page 10.
Everywhere there are boats—boats of all sizes and shapes, and
without number. Many of these belong to the Chinese, and bear
upon the prow a very realistic representation of an eye; for, says
John Chinaman, "If boat no got eye, how can him see?" Siamese
boats are chiefly canoes, or long, narrow, heavy rua-changs. Both
classes of boats are built of teak, a wood which is plentiful and
cheap, and which is not attacked by the so-called "white ant." The
canoes are paddled in the ordinary way, but they are very
upsettable. Many of these will not even sit upright in the water
unless someone gets inside. Yet great fat men, whose weight sinks
the boat to the very edge of the water, and tiny children, whose
weight looks little more than nothing, can be seen at all hours of the
day darting here and there, like so many flies, on the surface of the
water.
The rua-changs are larger, and are used for carrying people about
from one part of the river to another. They serve the same purpose
as our omnibuses. The boatman, who is naked except for a cloth
round the loins, stands to his work like a Venetian gondolier. He has
only one oar, which works in a groove cut in the side of a short pole
that is fixed on the edge of the boat. With long graceful sweeps of
the heavy oar the boatman both steers and propels his craft at the
same time. The passengers are squatting under paper umbrellas,
which keep off a little of the heat of the sun, and blinking behind the
blue spectacles that guard their eyes from the powerful and painful
reflection of the sun upon the shining waters.
As the capital is left behind the houses get fewer and fewer along
the banks, and the trees come right down to the edge of the river.
On either side of us, as the mouth is neared, there are dreary salt
marshes, which are often flooded by the sea when the tides are
high. On the banks, the fern-like attap-palm, that lover of the mud,
bends over in graceful curves to dip the ends of its long fronds in the
dirty water. Just behind, on firmer ground, rise the stately coco-nut
and areca-nut palms. An eastern saying states: "The coco-nut will
not thrive far from the sound of the human voice." Whether the
coco-nut loves the sound of the Siamese voice or not it is, perhaps,
not possible to say, but certain it is that the Siamese loves the coco-
nut palm, on account of the many useful things that he can get from
it. The young coco-nut is quite a different thing from that seen in
our shops about Christmas-time. In its early stages it resembles a
huge, unripe green plum. Outside there is a smooth green skin, like