978-1337102087 Chapter 8

subject Type Homework Help
subject Pages 9
subject Words 654
subject Authors D. S. Malik

Unlock document.

This document is partially blurred.
Unlock all pages and 1 million more documents.
Get Access
page-pf1
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 1
1. All components of an array are of the same data type.
a.
True
b.
False
ANSWER:
True
POINTS:
1
REFERENCES:
523
QUESTION TYPE:
True / False
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/30/2016 12:46 PM
2. The array index can be any integer less than the array size.
a.
True
b.
False
ANSWER:
False
POINTS:
1
REFERENCES:
525
QUESTION TYPE:
True / False
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/30/2016 12:46 PM
3. The statement int list[25]; declares list to be an array of 26 components, since the array index starts at 0.
a.
True
b.
False
ANSWER:
False
POINTS:
1
REFERENCES:
525
QUESTION TYPE:
True / False
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/30/2016 12:46 PM
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.
a.
True
b.
False
ANSWER:
False
POINTS:
1
REFERENCES:
526
QUESTION TYPE:
True / False
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
page-pf2
Name:
Class:
Date:
page-pf3
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 3
b.
False
ANSWER:
True
POINTS:
1
REFERENCES:
539
QUESTION TYPE:
True / False
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/30/2016 12:46 PM
9. The one place where C++ allows aggregate operations on arrays is the input and output of C-strings.
a.
True
b.
False
ANSWER:
True
POINTS:
1
REFERENCES:
556, 558
QUESTION TYPE:
True / False
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/30/2016 12:46 PM
10. In a two-dimensional array, the elements are arranged in a table form.
a.
True
b.
False
ANSWER:
True
POINTS:
1
REFERENCES:
575
QUESTION TYPE:
True / False
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/30/2016 12:46 PM
11. Which of the following statements declares alpha to be an array of 25 components of the type int?
a.
int alpha[25];
b.
int array alpha[25];
c.
int alpha[2][5];
d.
int array alpha[25][25];
ANSWER:
a
POINTS:
1
REFERENCES:
524
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/30/2016 12:46 PM
12. Assume you have the following declaration char nameList[100];. Which of the following ranges is valid for
page-pf4
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 4
the index of the array nameList?
a.
0 through 99
b.
0 through 100
c.
1 through 100
d.
1 through 101
ANSWER:
a
POINTS:
1
REFERENCES:
525
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/30/2016 12:46 PM
13. Assume you have the following declaration int beta[50];. Which of the following is a valid element of beta?
a.
beta['2']
b.
beta['50']
c.
beta[0]
d.
beta[50]
ANSWER:
c
POINTS:
1
REFERENCES:
525
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/30/2016 12:46 PM
14. 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
b.
0 through 1000
c.
1 through 1001
d.
1 through 1000
ANSWER:
a
POINTS:
1
REFERENCES:
525
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/30/2016 12:46 PM
15. 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;
page-pf5
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 5
ANSWER:
c
POINTS:
1
REFERENCES:
528
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/30/2016 12:46 PM
16. 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.
for (int j = 1; j < 10; j++)
cout << list[j] << " ";
cout << endl;
b.
for (int j = 0; j <= 9; j++)
cout << list[j] << " ";
cout << endl;
c.
for (int j = 1; j < 11; j++)
cout << list[j] << " ";
cout << endl;
d.
for (int j = 1; j <= 10; j++)
cout << list[j] << " ";
cout << endl;
ANSWER:
b
POINTS:
1
REFERENCES:
528
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/30/2016 12:46 PM
17. What is the output of the following C++ code?
int list[5] = {0, 5, 10, 15, 20};
int j;
for (j = 0; j < 5; j++)
cout << list[j] << " ";
cout << endl;
a.
0 1 2 3 4
b.
0 5 10 15
c.
0 5 10 15 20
d.
5 10 15 20
page-pf6
Name:
Class:
Date:
page-pf7
Name:
Class:
Date:
page-pf8
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 8
d.
int alpha[] = (3, 5, 7, 9, 11);
ANSWER:
a
POINTS:
1
REFERENCES:
532
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/30/2016 12:46 PM
23. In C++, the null character is represented as ____.
a.
'\0'
b.
"\0"
c.
'0'
d.
"0"
ANSWER:
a
POINTS:
1
REFERENCES:
553
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/30/2016 12:46 PM
24. 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';
ANSWER:
c
POINTS:
1
REFERENCES:
554
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/30/2016 12:46 PM
25. 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");
ANSWER:
c
POINTS:
1
REFERENCES:
554
QUESTION TYPE:
Multiple Choice
page-pf9
Name:
Class:
Date:
page-pfa
Name:
Class:
Date:
page-pfb
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 11
1 1
2 2
2 3
4 5
c.
0 1
1 2
2 3
d.
1 1
2 2
3 3
ANSWER:
c
POINTS:
1
REFERENCES:
568
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/30/2016 12:46 PM
32. Given the following declaration:
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];
ANSWER:
b
POINTS:
1
REFERENCES:
569
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/30/2016 12:46 PM
33. Given the following declaration:
page-pfc
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 12
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];
ANSWER:
d
POINTS:
1
REFERENCES:
569
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/30/2016 12:46 PM
34. In row order form, the ____.
a.
first row is stored first
b.
first row is stored last
c.
first column is stored first
d.
first column is stored last
ANSWER:
a
POINTS:
1
REFERENCES:
570
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/30/2016 12:46 PM
35. A collection of a fixed number of elements (called components) arranged in n dimensions (n >= 1) is called a(n) ____.
a.
matrix
b.
vector
c.
n-dimensional array
d.
parallel array
ANSWER:
c
POINTS:
1
REFERENCES:
575
QUESTION TYPE:
Multiple Choice
page-pfd
Name:
Class:
Date:
page-pfe
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 14
statements
ANSWER:
range-based
range based
POINTS:
1
REFERENCES:
551-552
QUESTION TYPE:
Completion
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/30/2016 12:46 PM

Trusted by Thousands of
Students

Here are what students say about us.

Copyright ©2022 All rights reserved. | CoursePaper is not sponsored or endorsed by any college or university.