Deck 3: Inputoutput
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/40
Play
Full screen (f)
Deck 3: Inputoutput
1
Suppose that x and y are int variables, and z is a double variable.The input is: 28 32.6 12
Choose the values of x, y, and z after the following statement executes:
Cin >> x >> y >> z;
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
Choose the values of x, y, and z after the following statement executes:
Cin >> x >> y >> z;
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
A
2
You can use the function getline to read a string containing blanks.
True
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;
cin >> x;
cin >> y;
False
4
If input failure occurs in a C++ program, the program terminates immediately and displays an error message.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
5
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;
A) cin >> x >> cin >> y;
B) cin >> x >> y;
C) cin << x << y;
D) cout << x << y;
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
6
Suppose that ch1, ch2, and ch3 are variables of the type char.The input is: A B
C
Choose the value of ch3 after the following statement executes:
Cin >> ch1 >> ch2 >> ch3;
A) 'A'
B) 'B'
C) 'C'
D) '\n'
C
Choose the value of ch3 after the following statement executes:
Cin >> ch1 >> ch2 >> ch3;
A) 'A'
B) 'B'
C) 'C'
D) '\n'
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
7
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'
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'
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
8
The number of input data extracted by cin and >> depends on the number of variables appearing in the cin statement.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
9
Suppose that x is an int variable, y is a double variable, and z is an int variable.The input is: 15 76.3 14
Choose the values after the following statement executes:
Cin >> x >> y >> z;
A) x = 15, y = 76, z = 14
B) x = 15, y = 76, z = 0
C) x = 15, y = 76.3, z = 14
D) x = 15.0, y = 76.3, z = 14.0
Choose the values after the following statement executes:
Cin >> x >> y >> z;
A) x = 15, y = 76, z = 14
B) x = 15, y = 76, z = 0
C) x = 15, y = 76.3, z = 14
D) x = 15.0, y = 76.3, z = 14.0
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
10
Suppose that x is an int variable and y is a double variable.The input is: 10 20.7
Choose the values after the following statement executes: cin >> x >> y;.
A) x = 10, y = 20
B) x = 10, y = 20.0
C) x = 10, y = 20.7
D) x = 10, y = 21.0
Choose the values after the following statement executes: cin >> x >> y;.
A) x = 10, y = 20
B) x = 10, y = 20.0
C) x = 10, y = 20.7
D) x = 10, y = 21.0
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
11
In the statement cin >> x;, x can be a variable or an expression.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
12
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
A) ch = '2', x = 76
B) ch = '276', x = '.'
C) ch = ' ', x = 276
D) ch = 'b', x = 76
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
13
When reading data into a char variable, after skipping any leading whitespace characters, the extraction operator >> finds and stores only the next character; reading stops after a single character.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
14
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.
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.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
15
The extraction operator >> skips only all leading blanks when searching for the next data in the input stream.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
16
In an output statement, each occurrence of endl advances the cursor to the end of the current line on an output device.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
17
Suppose that ch1 and ch2 are char variables, and alpha is an int variable.The input is: A 18
What are the values after the following statement executes?
Cin)get(ch1);
Cin)get(ch2);
Cin >> alpha;
A) ch1 = 'A', ch2 = ' ', alpha = 18
B) ch1 = 'A', ch2 = '1', alpha = 8
C) ch1 = 'A', ch2 = ' ', alpha = 1
D) ch1 = 'A', ch2 = '\n', alpha = 1
What are the values after the following statement executes?
Cin)get(ch1);
Cin)get(ch2);
Cin >> alpha;
A) ch1 = 'A', ch2 = ' ', alpha = 18
B) ch1 = 'A', ch2 = '1', alpha = 8
C) ch1 = 'A', ch2 = ' ', alpha = 1
D) ch1 = 'A', ch2 = '\n', alpha = 1
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
18
It is a good idea to redefine cin and cout in your programs.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
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
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
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
20
Entering a char value into an int variable causes serious errors, called input failure.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
21
Suppose that x = 25.67, y = 356.876, and z = 7623.9674.What is the output of the following statements? 
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

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
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
22
What is the output of the following statements? 
A) 123456789012345678901234567890
####Mickey Donald*****Goofy
B) 123456789012345678901234567890
####Mickey####Donald*****Goofy
C) 123456789012345678901234567890
####Mickey####Donald#####Goofy
D) 23456789012345678901234567890
****Mickey####Donald#####Goofy

A) 123456789012345678901234567890
####Mickey Donald*****Goofy
B) 123456789012345678901234567890
####Mickey####Donald*****Goofy
C) 123456789012345678901234567890
####Mickey####Donald#####Goofy
D) 23456789012345678901234567890
****Mickey####Donald#####Goofy
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
23
Suppose that x = 55.68, y = 476.859, and z = 23.8216.What is the output of the following statements? 
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

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
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
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 >> ch1;
Ch2 = cin.peek();
Cin >> ch2;
A) W
B) X
C) Y
D) Z
Cin >> ch1;
Ch2 = cin.peek();
Cin >> ch2;
A) W
B) X
C) Y
D) Z
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
25
In C++, the dot is an operator called the ____________________operator.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
26
C++ has a special name for the data types istream and ostream.They are called ____________________.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
27
In C++, the dot is an operator called the ____ operator.
A) dot access
B) member access
C) data access
D) member
A) dot access
B) member access
C) data access
D) member
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
28
Suppose that x = 1565.683, y = 85.78, and z = 123.982.What is the output of the following statements? 
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

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
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
29
C++ comes with a wealth of functions, called ____________________ functions, that are written by other programmers.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
30
Suppose that alpha, beta, and gamma are int variables and the input is: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
Cin)ignore(100, '\n');
Cin >> beta;
Cin)ignore(100,'\n');
Cin >> gamma;

A) 100
B) 200
C) 300
D) 320
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
31
Suppose that ch1, ch2, and ch3 are variables of the type char.The input is: A B
C
What is the value of ch3 after the following statements execute?
Cin)get(ch1);
Cin)get(ch2);
Cin)get(ch3);
A) 'A'
B) 'B'
C) 'C'
D) '\n'
C
What is the value of ch3 after the following statements execute?
Cin)get(ch1);
Cin)get(ch2);
Cin)get(ch3);
A) 'A'
B) 'B'
C) 'C'
D) '\n'
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
32
Manipulators without parameters are part of the ____ header file.
A) iostream
B) iomanip
C) ifstream
D) pmanip
A) iostream
B) iomanip
C) ifstream
D) pmanip
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
33
What is the output of the following statements? 
A) 12345678901234567890
***18 Happy Sleepy
B) 12345678901234567890
***18**Happy**Sleepy
C) 12345678901234567890
***18**Happy Sleepy
D) 12345678901234567890
***18**Happy Sleepy**

A) 12345678901234567890
***18 Happy Sleepy
B) 12345678901234567890
***18**Happy**Sleepy
C) 12345678901234567890
***18**Happy Sleepy
D) 12345678901234567890
***18**Happy Sleepy**
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
34
C++ provides a header file called ____________________, which is used for file I/O.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
35
When you want to process only partial data, you can use the stream function ____ to discard a portion of the input.
A) clear
B) skip
C) delete
D) ignore
A) clear
B) skip
C) delete
D) ignore
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
36
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
Cin)get(ch1);
Cin)putback(ch1);
Cin >> ch2;
A) W
B) X
C) Y
D) Z
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
37
Consider the following program segment. Which of the following statements at Line 3 can be used to open the file progdata.dat and input data from this file into x and y at Line 4?

A) inFile.open("progdata.dat");
B) inFile(open,"progdata.dat");
C) open.inFile("progdata.dat");
D) open(inFile,"progdata.dat");

A) inFile.open("progdata.dat");
B) inFile(open,"progdata.dat");
C) open.inFile("progdata.dat");
D) open(inFile,"progdata.dat");
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
38
____ is a parameterized stream manipulator.
A) endl
B) fixed
C) scientific
D) setfill
A) endl
B) fixed
C) scientific
D) setfill
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
39
The function ____________________ returns the next character in the input stream; it does not remove the character from the input stream.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
40
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");
A) outFile("outputData.out");
B) outFile.open("outputData.out");
C) open(outFile,"outputData.out");
D) open.outFile("outputData.out");
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck