Problem Solving with C++ 9th Edition Savitch Test Bank download
Problem Solving with C++ 9th Edition Savitch Test Bank download
https://testbankfan.com/product/problem-solving-with-c-9th-
edition-savitch-test-bank/
https://testbankfan.com/product/problem-solving-with-c-9th-
edition-savitch-solutions-manual/
https://testbankfan.com/product/problem-solving-with-c-10th-
edition-savitch-test-bank/
https://testbankfan.com/product/problem-solving-with-c-10th-
edition-savitch-solutions-manual/
https://testbankfan.com/product/engineering-problem-solving-
with-c-4th-edition-etter-test-bank/
Engineering Problem Solving With C++ 4th Edition Etter
Solutions Manual
https://testbankfan.com/product/engineering-problem-solving-
with-c-4th-edition-etter-solutions-manual/
https://testbankfan.com/product/data-abstraction-and-problem-
solving-with-c-walls-and-mirrors-6th-edition-carrano-test-bank/
https://testbankfan.com/product/data-abstraction-and-problem-
solving-with-c-walls-and-mirrors-7th-edition-carrano-test-bank/
https://testbankfan.com/product/data-abstraction-and-problem-
solving-with-c-walls-and-mirrors-6th-edition-carrano-solutions-
manual/
https://testbankfan.com/product/data-abstraction-and-problem-
solving-with-c-walls-and-mirrors-7th-edition-carrano-solutions-
manual/
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
Exploring the Variety of Random
Documents with Different Content
sellainen kuin kerran on maailmanmeno, minä näen, että täytyy olla
kaikkeen valmistunut.
Minulle oli siitä vähemmän hyötyä kuin hra d'Astarac luuli. Häntä
kuunnellessani olin levoton aivan toisista syistä. Tuo rauhattomuus
kuvastui epäilemättä kasvoillani, sillä suuri salatieteilijä loi katseensa
minuun ja kysyi, enkö pelännyt niin ankarien rangaistusten aitaaman
lemmensuhteen olevan epämukavan nuoruudelleni.
18.