978-1337102087 Chapter 3

subject Type Homework Help
subject Pages 9
subject Words 1511
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. It is a good idea to redefine cin and cout in your programs.
a.
True
b.
False
ANSWER:
False
POINTS:
1
REFERENCES:
125
QUESTION TYPE:
True / False
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:37 PM
DATE MODIFIED:
10/5/2016 1:37 PM
2. In the statement cin >> x;, x can be a variable or an expression.
a.
True
b.
False
ANSWER:
False
POINTS:
1
REFERENCES:
125
QUESTION TYPE:
True / False
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:37 PM
DATE MODIFIED:
10/5/2016 1:37 PM
3. The following statements will result in input failure if the input values are not on a separate line. (Assume that x and y
are int variables.)
cin >> x;
cin >> y;
a.
True
b.
False
ANSWER:
False
POINTS:
1
REFERENCES:
130
QUESTION TYPE:
True / False
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:37 PM
DATE MODIFIED:
10/5/2016 1:37 PM
4. The number of input data extracted by cin and >> depends on the number of variables appearing in the cin
statement.
a.
True
b.
False
ANSWER:
True
POINTS:
1
REFERENCES:
126
page-pf2
Name:
Class:
Date:
page-pf3
Name:
Class:
Date:
page-pf4
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 4
12. Suppose that x and y are int variables. Which of the following is a valid input statement?
a.
cin >> x >> cin >> y;
b.
cin >> x >> y;
c.
cin << x << y;
d.
cout << x << y;
ANSWER:
b
POINTS:
1
REFERENCES:
125-126
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:37 PM
DATE MODIFIED:
10/5/2016 1:37 PM
13. Suppose that x is an int variable, y is a double variable, and ch is a char variable. The input is:
15A 73.2
Choose the values after the following statement executes:
cin >> x >> ch >> y;
a.
x = 15, ch = 'A', y = 73.2
b.
x = 15, ch = 'A', y = 73.0
c.
x = 15, ch = 'a', y = 73.0
d.
This statement results in an error because there is no space between 15 and A.
ANSWER:
a
POINTS:
1
REFERENCES:
127-128
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:37 PM
DATE MODIFIED:
10/16/2016 9:08 AM
14. Suppose that alpha is an int variable and ch is a char variable. The input is:
17 A
What are the values after the following statements execute?
cin >> alpha;
cin >> ch;
a.
alpha = 17, ch = ' '
b.
alpha = 1, ch = 7
c.
alpha = 17, ch = 'A'
d.
alpha = 17, ch = 'a'
ANSWER:
c
POINTS:
1
REFERENCES:
128
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
page-pf5
Name:
Class:
Date:
page-pf6
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 6
a.
x = 28, y = 32, z = 0.6
b.
x = 28, y = 32, z = 12.0
c.
x = 28, y = 12, z = 32.6
d.
x = 28, y = 12, z = 0.6
ANSWER:
a
POINTS:
1
REFERENCES:
127-129
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:37 PM
DATE MODIFIED:
10/16/2016 9:12 AM
18. Suppose that x is an int variable, ch is a char variable, and the input is:
276.
Choose the values after the following statement executes:
cin >> ch >> x;
a.
ch = '2', x = 76
b.
ch = '276', x = '.'
c.
ch = ' ', x = 276
d.
ch = 'b', x = 76
ANSWER:
a
POINTS:
1
REFERENCES:
129
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:37 PM
DATE MODIFIED:
10/5/2016 1:37 PM
19. Suppose that x and y are int variables, ch is a char variable, and the input is:
4 2 A 12
Choose the values of x, y, and ch after the following statement executes:
cin >> x >> ch >> y;
a.
x = 4, ch = 2, y = 12
b.
x = 4, ch = A, y = 12
c.
x = 4, ch = ' ', y = 2
d.
This statement results in input failure
ANSWER:
d
POINTS:
1
REFERENCES:
130
QUESTION TYPE:
Multiple Choice
page-pf7
Name:
Class:
Date:
page-pf8
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 8
a.
'A'
b.
'B'
c.
'C'
d.
'\n'
ANSWER:
b
POINTS:
1
REFERENCES:
134
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:37 PM
DATE MODIFIED:
10/16/2016 9:14 AM
23. Suppose that alpha, beta, and gamma are int variables and the input is:
100 110 120
200 210 220
300 310 320
What is the value of gamma after the following statements execute?
cin >> alpha;
cin.ignore(100, '\n');
cin >> beta;
cin.ignore(100,'\n');
cin >> gamma;
a.
100
b.
200
c.
300
d.
320
ANSWER:
c
POINTS:
1
REFERENCES:
135
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:37 PM
DATE MODIFIED:
10/5/2016 1:37 PM
24. Suppose that ch1 and ch2 are char variables and the input is:
WXYZ
What is the value of ch2 after the following statements execute?
cin.get(ch1);
cin.putback(ch1);
cin >> ch2;
a.
W
b.
X
c.
Y
d.
Z
page-pf9
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 9
ANSWER:
a
POINTS:
1
REFERENCES:
137-138
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:37 PM
DATE MODIFIED:
10/5/2016 1:37 PM
25. Suppose that ch1 and ch2 are char variables and the input is:
WXYZ
What is the value of ch2 after the following statements execute?
cin >> ch1;
ch2 = cin.peek();
cin >> ch2;
a.
W
b.
X
c.
Y
d.
Z
ANSWER:
b
POINTS:
1
REFERENCES:
138
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:37 PM
DATE MODIFIED:
10/5/2016 1:37 PM
26. In C++, the dot is an operator called the ____ operator.
a.
dot access
b.
member access
c.
data access
d.
member
ANSWER:
b
POINTS:
1
REFERENCES:
139
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:37 PM
DATE MODIFIED:
10/16/2016 12:05 PM
27. Suppose that x = 25.67, y = 356.876, and z = 7623.9674. What is the output of the following statements?
cout << fixed << showpoint;
cout << setprecision(2);
cout << x << ' ' << y << ' ' << z << endl;
page-pfa
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 10
a.
25.67 356.87 7623.96
b.
25.67 356.87 7623.97
c.
25.67 356.88 7623.97
d.
25.67 356.876 7623.967
ANSWER:
c
POINTS:
1
REFERENCES:
145-147
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:37 PM
DATE MODIFIED:
10/5/2016 1:37 PM
28. Suppose that x = 55.68, y = 476.859, and z = 23.8216. What is the output of the following statements?
cout << fixed << showpoint;
cout << setprecision(3);
cout << x << ' ' << y << ' ' << setprecision(2) << z << endl;
a.
55.680 476.859 23.82
b.
55.690 476.860 23.82
c.
55.680 476.860 23.82
d.
55.680 476.859 23.821
ANSWER:
a
POINTS:
1
REFERENCES:
145-147
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:37 PM
DATE MODIFIED:
10/5/2016 1:37 PM
29. Suppose that x = 1565.683, y = 85.78, and z = 123.982. What is the output of the following statements?
cout << fixed << showpoint;
cout << setprecision(3) << x << ' ';
cout << setprecision(4) << y << ' ' << setprecision(2) << z << endl;
a.
1565.683 85.8000 123.98
b.
1565.680 85.8000 123.98
c.
1565.683 85.7800 123.98
d.
1565.683 85.780 123.980
ANSWER:
c
POINTS:
1
REFERENCES:
145-147
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:37 PM
DATE MODIFIED:
10/5/2016 1:37 PM
page-pfb
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 11
30. What is the output of the following statements?
cout << setfill('*');
cout << "12345678901234567890" << endl
cout << setw(5) << "18" << setw(7) << "Happy"
<< setw(8) << "Sleepy" << endl;
a.
12345678901234567890
***18 Happy Sleepy
b.
12345678901234567890
***18**Happy**Sleepy
c.
12345678901234567890
***18**Happy Sleepy
d.
12345678901234567890
***18**Happy Sleepy**
ANSWER:
b
POINTS:
1
REFERENCES:
152-153
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:37 PM
DATE MODIFIED:
10/5/2016 1:37 PM
31. What is the output of the following statements?
cout << "123456789012345678901234567890" << endl
cout << setfill('#') << setw(10) << "Mickey"
<< setfill(' ') << setw(10) << "Donald"
<< setfill('*') << setw(10) << "Goofy" << endl;
a.
123456789012345678901234567890
####Mickey Donald*****Goofy
b.
123456789012345678901234567890
####Mickey####Donald*****Goofy
c.
123456789012345678901234567890
####Mickey####Donald#####Goofy
d.
23456789012345678901234567890
****Mickey####Donald#####Goofy
ANSWER:
a
page-pfc
Name:
Class:
Date:
page-pfd
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 13
d.
open(inFile,"progdata.dat");
ANSWER:
a
POINTS:
1
REFERENCES:
172
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:37 PM
DATE MODIFIED:
10/5/2016 1:37 PM
35. Suppose that outFile is an ofstream variable and output is to be stored in the file outputData.out. Which of
the following statements opens the file outputData.out and associates outFile to the output file?
a.
outFile("outputData.out");
b.
outFile.open("outputData.out");
c.
open(outFile,"outputData.out");
d.
open.outFile("outputData.out");
ANSWER:
b
POINTS:
1
REFERENCES:
172
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:37 PM
DATE MODIFIED:
10/5/2016 1:37 PM
36. The function ____________________ returns the next character in the input stream; it does not remove the character
from the input stream.
ANSWER:
peek
POINTS:
1
REFERENCES:
137
QUESTION TYPE:
Completion
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:37 PM
DATE MODIFIED:
10/5/2016 1:37 PM
37. C++ comes with a wealth of functions, called ____________________ functions, that are written by other
programmers.
ANSWER:
predefined
pre defined
pre-defined
POINTS:
1
REFERENCES:
130-131
QUESTION TYPE:
Completion
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:37 PM
DATE MODIFIED:
10/5/2016 1:37 PM
page-pfe
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 14
38. C++ has a special name for the data types istream and ostream. They are called ____________________.
ANSWER:
classes
POINTS:
1
REFERENCES:
139
QUESTION TYPE:
Completion
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:37 PM
DATE MODIFIED:
10/5/2016 1:37 PM
39. In C++, the dot is an operator called the ____________________operator.
ANSWER:
member access
POINTS:
1
REFERENCES:
139
QUESTION TYPE:
Completion
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:37 PM
DATE MODIFIED:
10/5/2016 1:37 PM
40. C++ provides a header file called ____________________, which is used for file I/O.
ANSWER:
fstream
POINTS:
1
REFERENCES:
161
QUESTION TYPE:
Completion
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:37 PM
DATE MODIFIED:
10/5/2016 1:37 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.