This is a blue quiz. The people to your left and right should have a red quiz. |
Print your name here____________________________________________________ ID#___________________
Please write your answers on the this sheet, and PRINT your name and ID number above. This quiz covers file I/O operations from Secs. 8.3 through 8.5, as well as the basics of arrays, from Secs. 9.1 and 9.2
Question 1.
Assuming the declaration
ifstream inFile;
rrite the conditional expression for a while loop that can simultaneously get a character
into the character variable ch using get()
and also check for end-of-file condition for inFile.
HINT: The syntax of the open() and get() functions is similar.
Question 2.
Show how to use inFile (defined in Question 1) with the
<< or >>
operator to read an integer
into the integer variable n. (Choose the correct operator.)
Question 3.
What value does the function fail() return if a stream open fails?
Question 7.
What do the following statements do? For each part of the question below, a-f,
start fresh with the array int ar[] = {1, 3, 8, 2, 17}.
for(int i = 0; i < ab[2]; i += 2) cout << ab[i] << ' ';