CPE211- Ch 4 Study Guide

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

D

Given the two lines of input data ABC DEF what value is read into ch by the following code? (str is of type string, and ch is of type char.) getline(cin, str); cin.get(ch); A. 'B' B. ' ' (blank) C. 'C' D. 'D' E. none of the above

ifstream

The C++ standard library defines a data type named ____________________ that represents a stream of characters coming from an input file.

ofstream

The C++ standard library defines a data type named ____________________ that represents a stream of characters going to an output file.

D

Which of the following statements sends a newline character to the standard output device? A. cout << endl; B. cout << '\n'; C. cout << D. a and b above E. a, b, and c above

C

Given the line of input data 123.456 A 789 what value is read into inputChar by the following code? (alpha and beta are of type int, and inputChar is of type char.)cin >> alpha >> inputChar >> beta; A. ' ' (blank) B. 'A' C. '.' (period) D. '4' E. none of the above

C

Given the three lines of input data 111 222 333 444 555 666 777 888 999 what value is read into gamma by the following code? (All variables are of type int.)cin >> alpha;cin.ignore(500, '\n');cin >> beta >> gamma; A. 333 B. 444 C. 555 D. 777 E. none of the above

C

Given the two lines of input data A B CDE what value is read into ch3 by the following code? (All variables are of type char.)cin >> ch1 >> ch2 >> ch3; A. 'B' B. ' ' (blank) C. 'C' D. 'D' E. none of the above

A

Given the two lines of input data A B CDE what value is read into ch3 by the following code? (All variables are of type char.)cin.get(ch1);cin.get(ch2);cin.get(ch3); A. 'B' B. ' ' (blank) C. 'C' D. 'D' E. none of the above

echo printing

____________________ is the act of printing out all of the input values so that the user can verify that they were entered correctly.

E

A value can be stored into a variable by execution of: A. an input statement B. an output statement C. an assignment statement D. a and b above E. a and c above

prompt

A(n) ____________________ is a printed message that indicates what the user should enter as input.

whitespace

Blanks and newline characters in an input stream are examples of ____________________ characters.

D

Given the two lines of input data ABC DEF what value is read into ch by the following code? (str is of type string, and ch is of type char.) cin >> str; cin.get(ch); A. 'B' B. ' ' (blank) C. 'C' D. 'D' E. none of the above

E

Given the constant declaration const int FACTOR = 95; which of the following is not a valid use of FACTOR? A. cout << FACTOR * 3; B. FACTOR = 24; C. cin >> FACTOR; D. a and c above E. b and c above

E

If we want a program to use file I/O for reading or writing, the following four things must be done EXCEPT: A. Request the preprocessor to include the header file fstream. B. Use declaration statements to declare the file streams we will use. C. Prepare each file for reading or writing by using a function named open. D. Specify the name of the file stream in each input or output statement E. Ensure that each individual file to be read or written contains a strictly limited amount of data.

fail

Once a C++ I/O stream has entered the ____________________ state, any further operations using that stream are considered to be null operations.

D

What happens when a C++ input stream enters the fail state? A. The system displays an error message, and program execution is terminated. B. The system displays an error message, the program continues running, and further input operations with that stream are ignored. C. The system does not display an error message, and program execution is terminated. D. The system does not display an error message, the program continues running, and further input operations with that stream are ignored. E. none of the above

E

When used with an input file stream, which of the following statements about the open function is false? A. It associates the name of a stream variable with the name of a physical disk file. B. It puts the stream into the fail state if the file does not already exist. C. It sets the reading marker at the first character in the file. D. It creates a new, empty file if the file does not already exist. E. none of the above

B

Which of the following code segments could be used to skip the first two characters of an input line (they may or may not be whitespace characters) and input the integer value that comes next? (Variable dummy is of type char, and inputInt is of type int.) A. cin >> dummy >> dummy >> inputInt; B. cin.get(dummy);cin.get(dummy);cin >> inputInt; C. cin >> inputInt; D. cin.get(' ');cin.get(' ');cin >> inputInt; E. a and c above

E

Which of the following correctly inputs the person's initials into the char variables firstInit and lastInit? A. cin >> firstInit >> lastInit; B. cin >> firstInit >> ' ' >> lastInit; C. cin >> firstInit;cin.ignore(1, ' ');cin >> lastInit; D. b and c above E. a and c above

A

Which of the following is a valid input statement? A. cin >> studentAge; B. cin << studentAge; C. studentAge >> cin; D. studentAge << cin; E. a and c above

D

Which of the following is considered interactive I/O? A. scanning a file of employee records and printing the names of salaried employees B. entering sales records into a file in response to prompts from the computer program C. reading a file of numbers and printing their average D. a, b, and c above

C

Which of the following is not a reason for using batch I/O? A. A large amount of input data is expected. B. The input data can be prepared ahead of time. C. Input prompts can be tailored to the experience level of the user. D. The output data can be examined at the user's leisure. E. The output from one program can be used as the input to another.

E

Which of the following is not one of the things a programmer must do in order to use files in a C++ program? A. Use a preprocessor directive to include the header file fstream. B. Declare each file stream in a variable declaration. C. Prepare each file for reading or writing by calling the open function. D. Specify the name of the file stream in each input or output statement that uses it. E. Erase the contents of each output file before running the program.

A

Which of the following statements about C++ stream input is true? A. When an integer data value is read into a float variable, the value is first converted into floating-point form. B. When an integer data value is read into a float variable, the float variable becomes an int variable. C. It is an error to read an integer data value into a float variable. D. Input of a floating-point data value stops when a decimal point is encountered. E. c and d above

E

Which of the following statements about functional decomposition is false? A. Modules are the basic building blocks of functional decomposition. B. Each level of a solution tree is more abstract (less detailed) than the level above it. C. A module can contain both abstract steps and concrete steps. D. A concrete step is a step that can be translated directly into C++ code. E. none of the above

C

Which of the following statements about object-oriented design (OOD) is false? A. OOD focuses on entities (objects) and operations on those objects. B. The first step in OOD is to identify the major objects in the problem, together with their associated operations. C. In OOD, data plays a secondary role in support of actions to be performed. D. Object-oriented programming languages have been developed specifically to support OOD. E. OOD and functional decomposition can be used in combination with each other to solve problems


Set pelajaran terkait

The 25th amendment and the 4 key sections

View Set

TTMIK Q&A Book: Chapter 1 Question 1: Sample Sentences

View Set

Homework 4: Formation of the Solar System

View Set

Relativity — Admin Essentials I

View Set