Full Download of C++ Programming From Problem Analysis to Program Design 6th Edition Malik Test Bank in PDF DOCX Format
Full Download of C++ Programming From Problem Analysis to Program Design 6th Edition Malik Test Bank in PDF DOCX Format
https://testbankdeal.com/product/c-programming-from-problem-analysis-
to-program-design-6th-edition-malik-solutions-manual/
testbankdeal.com
https://testbankdeal.com/product/c-programming-from-problem-analysis-
to-program-design-7th-edition-malik-test-bank/
testbankdeal.com
https://testbankdeal.com/product/c-programming-from-problem-analysis-
to-program-design-8th-edition-malik-test-bank/
testbankdeal.com
https://testbankdeal.com/product/pearsons-federal-
taxation-2018-comprehensive-31st-edition-rupert-solutions-manual/
testbankdeal.com
Basic Immunology Functions and Disorders of the Immune
System 4th Edition Abbas Test Bank
https://testbankdeal.com/product/basic-immunology-functions-and-
disorders-of-the-immune-system-4th-edition-abbas-test-bank/
testbankdeal.com
https://testbankdeal.com/product/nonlinear-systems-3rd-edition-khalil-
solutions-manual/
testbankdeal.com
https://testbankdeal.com/product/busn-5-5th-edition-kelly-test-bank/
testbankdeal.com
https://testbankdeal.com/product/guide-to-sql-9th-edition-pratt-
solutions-manual/
testbankdeal.com
https://testbankdeal.com/product/mf-4th-edition-knox-test-bank/
testbankdeal.com
Psychology 1st Edition Marin Test Bank
https://testbankdeal.com/product/psychology-1st-edition-marin-test-
bank/
testbankdeal.com
Chapter 8: Arrays and Strings
TRUE/FALSE
2. The array index can be any integer less than the array size.
3. The statement int list[25]; declares list to be an array of 26 components, since the array
index starts at 0.
4. Given the declaration int list[20]; the statement list[12] = list[5] + list[7];
updates the content of the twelfth component of the array list.
5. Suppose list is a one dimensional array of size 25, wherein each component is of type int. Further,
suppose that sum is an int variable. The following for loop correctly finds the sum of the elements
of list.
sum = 0;
6. If an array index goes out of bounds, the program always terminates in an error.
7. Arrays can be passed as parameters to a function by value, but it is faster to pass them by reference.
8. When you pass an array as a parameter, the base address of the actual array is passed to the formal
parameter.
9. The one place where C++ allows aggregate operations on arrays is the input and output of C-strings.
MULTIPLE CHOICE
1. Which of the following statements declares alpha to be an array of 25 components of the type int?
a. int alpha[25]; c. int alpha[2][5];
b. int array alpha[25]; d. int array alpha[25][25];
ANS: A PTS: 1 REF: 507-508
2. Assume you have the following declaration char nameList[100];. Which of the following
ranges is valid for the index of the array nameList?
a. 0 through 99 c. 1 through 100
b. 0 through 100 d. 1 through 101
ANS: A PTS: 1 REF: 509
3. Assume you have the following declaration int beta[50];. Which of the following is a valid
element of beta?
a. beta['2'] c. beta[0]
b. beta['50'] d. beta[50]
ANS: C PTS: 1 REF: 509
4. Assume you have the following declaration double salesData[1000];. Which of the following
ranges is valid for the index of the array salesData?
a. 0 through 999 c. 1 through 1001
b. 0 through 1000 d. 1 through 1000
ANS: A PTS: 1 REF: 509
5. Suppose that sales is an array of 50 components of type double. Which of the following correctly
initializes the array sales?
a. for (int 1 = 1; j <= 49; j++)
sales[j] = 0;
b. for (int j = 1; j <= 50; j++)
sales[j] = 0;
c. for (int j = 0; j <= 49; j++)
sales[j] = 0.0;
d. for (int j = 0; j <= 50; j++)
sales[j] = 0.0;
ANS: C PTS: 1 REF: 512
6. Suppose that list is an array of 10 components of type int. Which of the following codes correctly
outputs all the elements of list?
a. 0 1 2 3 4 c. 0 5 10 15 20
b. 0 5 10 15 d. 5 10 15 20
ANS: C PTS: 1 REF: 512
int alpha[5];
int j;
a. 1 c. 5
b. 4 d. 6
ANS: C PTS: 1 REF: 512
a. 2 4 6 8 10 c. 8 6 4 2 0
b. 4 3 2 1 0 d. 10 8 6 4 2
ANS: D PTS: 1 REF: 512
a. 0 5 10 15 20 c. 5 10 15 20 20
b. 5 10 15 20 0 d. Code results in index out-of-bounds
ANS: D PTS: 1 REF: 515-516
11. Suppose that gamma is an array of 50 components of type int and j is an int variable. Which of the
following for loops sets the index of gamma out of bounds?
a. for (j = 0; j <= 49; j++)
cout << gamma[j] << " ";
b. for (j = 1; j < 50; j++)
cout << gamma[j] << " ";
c. for (j = 0; j <= 50; j++)
cout << gamma[j] << " ";
d. for (j = 0; j <= 48; j++)
cout << gamma[j] << " ";
ANS: C PTS: 1 REF: 515-516
12. Consider the following declaration: int alpha[5] = {3, 5, 7, 9, 11};. Which of the
following is equivalent to this statement?
a. int alpha[] = {3, 5, 7, 9, 11};
b. int alpha[] = {3 5 7 9 11};
c. int alpha[5] = [3, 5, 7, 9, 11];
d. int alpha[] = (3, 5, 7, 9, 11);
ANS: A PTS: 1 REF: 516
14. Which of the following correctly declares name to be a character array and stores "William" in it?
a. char name[6] = "William";
b. char name[7] = "William";
c. char name[8] = "William";
d. char name[8] = 'William';
ANS: C PTS: 1 REF: 536
15. Consider the following declaration: char str[15];. Which of the following statements stores
"Blue Sky" into str?
a. str = "Blue Sky";
b. str[15] = "Blue Sky";
c. strcpy(str, "Blue Sky");
d. strcpy("Blue Sky");
ANS: C PTS: 1 REF: 537
16. Consider the following declaration:
char charArray[51];
char discard;
cin.get(charArray, 51);
cin.get(discard);
17. Consider the following statement: double alpha[10][5];. The number of components of
alpha is ____.
a. 15 c. 100
b. 50 d. 150
ANS: B PTS: 1 REF: 544
18. Consider the statement int list[10][8];. Which of the following about list is true?
a. list has 10 rows and 8 columns.
b. list has 8 rows and 10 columns.
c. list has a total of 18 components.
d. list has a total of 108 components.
ANS: A PTS: 1 REF: 544
19. Consider the following statement: int alpha[25][10];. Which of the following statements about
alpha is true?
a. Rows of alpha are numbered 0...24 and columns are numbered 0...9.
b. Rows of alpha are numbered 0...24 and columns are numbered 1...10.
c. Rows of alpha are numbered 1...24 and columns are numbered 0...9.
d. Rows of alpha are numbered 1...25 and columns are numbered 1...10.
ANS: A PTS: 1 REF: 544
20. Which of the following correctly declares and initializes alpha to be an array of four rows and three
columns with the component type int?
a. int alpha[4][3] = {{0,1,2} {1,2,3} {2,3,4} {3,4,5}};
b. int alpha[4][3] = {0,1,2; 1,2,3; 2,3,4; 3,4,5};
c. int alpha[4][3] = {0,1,2: 1,2,3: 2,3,4: 3,4,5};
d. int alpha[4][3] = {{0,1,2}, {1,2,3}, {2,3,4}, {3,4,5}};
ANS: D PTS: 1 REF: 546
21. After the following statements execute, what are the contents of matrix?
int matrix[3][2];
int j, k;
a. 0 0 c. 0 1
1 1 1 2
2 2 2 3
b. 0 1 d. 1 1
2 3 2 2
4 5 3 3
ANS: C PTS: 1 REF: 548-550
int j;
int sum;
double sale[10][7];
which of the following correctly finds the sum of the elements of the fifth row of sale?
a. sum = 0;
for(j = 0; j < 7; j++)
sum = sum + sale[5][j];
b. sum = 0;
for(j = 0; j < 7; j++)
sum = sum + sale[4][j];
c. sum = 0;
for(j = 0; j < 10; j++)
sum = sum + sale[5][j];
d. sum = 0;
for(j = 0; j < 10; j++)
sum = sum + sale[4][j];
ANS: B PTS: 1 REF: 550
int j;
int sum;
double sale[10][7];
which of the following correctly finds the sum of the elements of the fourth column of sale?
a. sum = 0;
for(j = 0; j < 7; j++)
sum = sum + sale[j][3];
b. sum = 0;
for(j = 0; j < 7; j++)
sum = sum + sale[j][4];
c. sum = 0;
for(j = 0; j < 10; j++)
sum = sum + sale[j][4];
d. sum = 0;
for(j = 0; j < 10; j++)
sum = sum + sale[j][3];
ANS: D PTS: 1 REF: 551
25. A collection of a fixed number of elements (called components) arranged in n dimensions (n>=1) is
called a(n) ____.
a. matrix c. n-dimensional array
b. vector d. parallel array
ANS: C PTS: 1 REF: 557
COMPLETION
1. A data type is called ____________________ if variables of that type can store only one value at a
time.
ANS: simple
2. In a(n) ____________________ data type, each data item is a collection of other data items.
ANS: structured
double sales[10];
int index;
ANS: sales[index]
4. The word ____________________ is used before the array declaration in a function heading to
prevent the function from modifying the array.
ANS: const
5. The ____________________ of an array is the address (that is, the memory location) of the first array
component.
ANS: base address
6. The ____________________ sort algorithm finds the location of the smallest element in the unsorted
portion of the list and moves it to the top of the unsorted portion of the list.
ANS: selection
7. For a list of length n, the ____________________ sort makes exactly (n(n - 1))/2 key
comparisons and 3(n-1) item assignments.
ANS: selection
ANS:
12
twelve
9. The function ____________________ returns the length of the string s, excluding the null character.
ANS: strlen(s)
ANS: 15
11. The following statements store the value ____________________ into len.
int len;
len = strlen("Sunny California");
ANS: 16
12. The header file string contains the function ____________________,which converts a value of type
string to a null-terminated character array.
ANS: c_str
PTS: 1 REF: 541
13. Two (or more) arrays are called ____________________ if their corresponding components hold
related information.
ANS: parallel
int alpha[10][25];
ANS:
10
ten
15. In the following declaration, the array gamma has ____________________ components.
int gamma[5][6][10];
ANS:
300
three hundred
Xim. O my father!
I know that horn too well.—’Tis but the wind,
Which, with a sudden rising, bears its deep
And savage war-note from us, wafting it
O’er the far hills.
Elm. My sons!
And canst thou name them?
Elm. Think’st thou all hearts like thine? Can mothers stand
To see their children perish?
Gon. (starting up.) Doth the Moor deem that I have part or
share
Or counsel in his vileness? Stay me not!
Let go thy hold—’tis powerless on me now:
I linger here, while treason is at work!
[Exit Gonzalez.
CHANT.
A sword is on the land!
He that bears down young tree and glorious flower,
Death is gone forth, he walks the wind in power!
Where is the warrior’s hand?
Our steps are in the shadows of the grave:
Hear us, we perish!—Father, hear and save!
Hernandez enters.
A Cit. We die!
[They take up the banner and follow Ximena out, their voices
are heard gradually dying away at a distance.
Abd. Speak!
Gon. (snatching the cross, and lifting it up.) Let the earth be
shaken through its depths,
But this must triumph!
Alph. Father!
Gon. Peace!
Who hath told thee how much man’s heart can bear?
—Lend me thine arm—my brain whirls fearfully—
How thick the shades close round! My boy! my boy!
Where art thou in this gloom?
Gar. I behold—
Oh, for a thousand Spaniards! to rush down——
Gar. A sword,
A sword, springs upward, like a lightning burst,
Through the dark serried mass! Its cold blue glare
Is wavering to and fro—’tis vanish’d—hark!
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
testbankdeal.com