Showing posts with label Chapter 05. Show all posts
Showing posts with label Chapter 05. Show all posts

Chapter 5 Quiz Starting Out With C++ 043

The _____ statement causes a loop to terminate early. The _____ statement causes a loop to stop its current iteration and begin the next one.

a.. continue, break
b. break, continue

Chapter 5 Quiz Starting Out With C++ 042

Reading and Writing files in C++.  How can you tell if a file was successfully opened in C++?

assume inFile was defined as an ifstream object

a. test ifstream and see if it is true
b. test inFile and check if it is true
c. test open(inFile) == true
d. check if inFile returns an error.

Chapter 5 Quiz Starting Out With C++ 041

Writing and Reading files in C++.  What can be used to read lines of data from a file?

a. the readLine() function
b. a loop
c. cin
d. inFile

Chapter 5 Quiz Starting Out With C++ 040

Reading and Writing files in C++.  Will the following segment of code read the name of a city?

ifstream inFile;
string city;

inFile.open("cities.txt");
cout << "Reading city name from the file.\n";

inFile >> city; // Read the city name from the file

a. true
b. false

Chapter 5 Quiz Starting Out With C++ 039

Writing and Reading files in C++.  The >> operator combined with an ifstream object can be used to read from a file?

a. true
b. false

Chapter 5 Quiz Starting Out With C++ 038

Writing and Reading files in C++.  Given that outFile has been defined with ofstream, which statement will write the data to a file?

a. cout(outFile) << " Hello Student";
b. cout << outFile << "Hello Student";
c. outFile << "Hello Student";
d. outFile -> "Hello Student";

Chapter 5 Quiz Starting Out With C++ 037

Writing and Reading a file in C++.  How do you close a file in C++?

a. ifstream inFile.close();
b. inFile.Close();
c. inFile.close();
d. close(inFile);

Chapter 5 Quiz Starting Out With C++ 036

Reading and Writing files in C++.  What does the following statement do?

ifstream inFile("NewHires.txt");

a. defines a input file stream  named inFile and opens the file NewHires.txt.
b. defines the input stream but does not open it.
c. checks to see if the file NewHires.txt exists
d. none of the above.  You can't do all that in one statement

Chapter 5 Quiz Starting Out With C++ 035

_____ backslashes are required to represent one blackslash when setting the path of a file in a string.

a. two
b. three
c. one

Chapter 5 Quiz Starting Out With C++ 034

Reading and Writing files in C++.  Is this how you set up a file for output in C++?

ofstream outFile;
outFile.open("Sales.txt");

a. true
b. false

Chapter 5 Quiz Starting Out With C++ 033

Writing and Reading files in C++.  The following is the correct way to set up a file for reading?

ifstream inFile;
inFile.open("Employees.txt");

a. true
b. false

Chapter 5 Quiz Starting Out With C++ 032

Reading and Writing files in C++.  _____ is used for output, _____ is used for input and _____ is used for reading or writing.

a.  fstream, ofstream, ifstream
b. ifstream, ofstream, fstream
c. ifstream, fstream, ofstream
d. fstream, fstream, fstream

Chapter 5 Quiz Starting Out With C++ 031

Reading and Writing files in C++.  _____ contains all the declarations necessary for file operations.

a. fileIOstream
b. file.h
c. fstream
d. fileReadWrite

Chapter 5 Quiz Starting Out With C++ 030

Writing and Reading files in C++.  What must be created in order to be able to work with files/

a. filesys link
b. file stream object
c. binary stream
d. random access link

Chapter 5 Quiz Starting Out With C++ 029

Writing and Reading files in C++.  Random access files or direct access files are considered the same thing?

a. true
b. false

Chapter 5 Quiz Starting Out With C++ 028

Reading and Writing files in C++.  Sequential access files can be accessed at any location in the file.  This may include forward and backwards?

a. true
b. false

Chapter 5 Quiz Starting Out With C++ 027

Reading a writing files in C++.  A _____ file can be easy read by human eyes, whereas a _____ file is more difficult.

a. binary, ASCII
b. ASCII, binary
c. text, ASCII
d. ASCII, text

Chapter 5 Quiz Starting Out With C++ 026

Using data files in C++.  What are the steps required for using a file in a program in C++?

a.  Process the file, Open the file, Close the file
b. Open the file, Process the file, Close the file
c. Close the file, Process the file, Open the file

Chapter 5 Quiz Starting Out With C++ 025

A loop that is inside another loop is called a _____?

a. internal loop
b. indented loop
c. blocked loop
d. nested loop

Chapter 5 Quiz Starting Out With C++ 024

The file temp.txt has the following values.  What is probably the sentinel value?

98, 101, 95, 93, 85, 73, 73, 75, 0

a. 98
b. 0
c. 85
d. \n