Deck 6: Io Streams As an Introduction to Objects and Classes

ملء الشاشة (f)
exit full mode
سؤال
Data that is sent to an output stream representing a file will be immediately saved to disk.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
When passing a stream to a function, it must always be pass-by-__________.
سؤال
A _____________ is a flow of characters or other data.
سؤال
All data is input and output as ____________ data.
سؤال
A type whose variables are objects is known as a ___________.
سؤال
'\n' is two characters.
سؤال
The formatting options that were discussed for cout do not work for output file streams.
سؤال
You may not have more than one input and one output stream open at any one time.
سؤال
A value that can be turned on or off is called a ________.
سؤال
You may use a read extraction) as a boolean expression in an if or while statement.
سؤال
The flag to always show the decimal point in floating numbers is ios:: _________
سؤال
The flag to display floating point numbers in non-scientific notation is ios:: _________
سؤال
Which command reads one character even if that character is a blank space? ___________
سؤال
open is a __________ function of the ofstream and ifstream class.
سؤال
You must use a width statement before each variable that you want output in a certain width
سؤال
Streams may be passed to a function.
سؤال
Using directives can be placed either directly after the include directives, or at the beginning of each function definition.
سؤال
The manipulator used to change the number of decimal places displayed is _________
سؤال
If you use the width command, it stays in effect for all values that are send to the stream.
سؤال
Two different objects of the same class have a different set of member functions.
سؤال
In the following function declaration, the istream object cin is called a ___________________.
void outputistream& in=cin);
سؤال
Which of the following is the correct way to close a file stream named outFile?

A) outFile.close);
B) outFile.close;
C) outFile.close"project.txt");
D) closeoutFile);
سؤال
To open a file with a user supplied name, you would need to store the name in a variable. If the file name was to have no more than 20 characters in it, which would be an appropriate declaration of the file name variable?

A) char filename;
B) char filename20);
C) char filename[20];
D) char filename[21];
سؤال
Which include directive is necessary for file IO

A) #include
B) #include
C) #include
D) #include
سؤال
If a file did not open correctly, you should

A) continue on anyway
B) display an error message and continue on
C) display an error message and take some suitable action such as exit
D) exit the program immediately
سؤال
After a stream is opened, before it is used for input and output, it should be

A) declared
B) closed
C) checked to see if it opened correctly
D) none of the above
سؤال
Which statement correctly opens an input stream named in_file and attaches it to a file name project.txt?

A) in_file=project.txt
B) in_file="project.txt"
C) in_file.open"project.txt");
D) in_file.openproject.txt);
سؤال
The member function setf stands for

A) set the file name
B) set the flags
C) set the format
D) nothing
سؤال
To open an output file and add to the end of the data already in the file you would write

A) outFile.open"project.txt");
B) outFile.append"project.txt");
C) outFile.open"project.txt", append);
D) outFile.open"project.txt", ios::app);
سؤال
The member function eof) is true/false) when we are ready to read the end of file character.
سؤال
When is the external name of the file used in the program?

A) Any time you read or write to the file
B) Never
C) Only when reading from the file
D) When opening the file stream
سؤال
A __________ is a variable that has functions as well as data associated with it.

A) member
B) int
C) object
D) float
سؤال
A function that is associated with an object is called a _________ function.

A) input
B) output
C) member
D) instantiated
سؤال
"\n" is a ________ and '\n' is a _______________.
سؤال
In order to read data from a file you

A) must know the kind of data in the file
B) do not need to know the kind of data in the file
C) should prompt the user for the data you are looking for
D) a and c
سؤال
Which of the following is not used when using files for input and output

A) Opening the file stream
B) Ensuring that the stream opened
C) Closing the stream
D) Prompting for file data
سؤال
The command outFile.precision2);

A) truncates all floating point variables to 2 decimal places
B) sets all output streams in your program to display 2 secimal places
C) displays integers as floating point numbers.
D) displays all floating point values sent to outFile with 2 decimal places.
سؤال
If the name of the input file was in a variable named filename, which of the following is the correct way to open the input stream named inFile and associate it with this file?

A) inFile.openfilename);
B) inFile=filename;
C) inFile="filename";
D) inFile.open"filename");
سؤال
Which of the following is the correct way to determine if a file stream named inFile opened correctly?

A) if inFile.open) )
B) if inFile.fail) )
C) if inFile.opened) )
D) if inFile.failed) )
سؤال
The _______ function puts one character back into the input stream.
سؤال
The get function reads

A) one integer value
B) one float value
C) one double value
D) one character value
سؤال
In order to use the stream manipulators, you must include the ______ library

A) manip
B) iomanip
C) cstdlib
D) fstream
سؤال
The command outFile.width10) is used to

A) change the number of characters in the output
B) sets the filename of outFile to 10 characters
C) always uses 10 characters to display the output
D) displays the next value in at least 10 characters
سؤال
What character will be in variable c after running this code?
Int x;
Char c;
Cin >> x;
Cin)getc);

A) Whatever character is typed by the user
B) Newline
C) Null
D) Blank
سؤال
What is wrong with the following code?
While ! fileIn.eof) )
{
FileIn >> value;
FileOut << value;
}

A) We have read past the end of the input file and attempt to output a nonexistent value
B) We have written past the end of the output file
C) Nothing
D) A and B
سؤال
We have a file that has a name in it, but the name is written one character per line. We need to write this name to the screen. What is wrong with the following code?
Ifstream fileIn;
FileIn.open"file.txt");
Char ch;
FileIn.getch)
While!fileIn.eof))
{
Cout.putch);
FileIn.getch);
}

A) can not use put with cout.
B) our output has new lines in it.
C) nothing is wrong
D) eof is not a member of an ifstream object
سؤال
Which of the following loop condition statements will read all the data in the file assuming that each record in the file is two integer values, and you will read the first one into a variable named intOne, and the other into intTwo?

A) whileinFile >> intOne >> intTwo)
B) whileinFileintOne, intTwo))
C) whileinFile)
D) whileinFile << intOne << intTwo)
E) A and B
سؤال
What is the output of the following code?
Char ch='G';
Cout << tolowerch) << endl;

A) G
B) g
C) the integer value of 'g'
D) the integer value of 'G'
سؤال
The put function outputs

A) one character value
B) one float value
C) one integer value
D) one double value
سؤال
If the user types in the characters 10, and your program reads them into an integer variable, what is the value stored into that integer?

A) 1
B) 0
C) 10
D) none of the above.
سؤال
ios::showpos is a flag that

A) always displays a + in front of positive integers
B) can be used to find the absolute value of an integer
C) always displays a + in front of all integers
D) all of the above
سؤال
Which function returns true if the character argument is a letter?

A) isdigit
B) islower
C) isalpha
D) isspace
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/52
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 6: Io Streams As an Introduction to Objects and Classes
1
Data that is sent to an output stream representing a file will be immediately saved to disk.
False
2
When passing a stream to a function, it must always be pass-by-__________.
reference
3
A _____________ is a flow of characters or other data.
stream
4
All data is input and output as ____________ data.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
5
A type whose variables are objects is known as a ___________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
6
'\n' is two characters.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
7
The formatting options that were discussed for cout do not work for output file streams.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
8
You may not have more than one input and one output stream open at any one time.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
9
A value that can be turned on or off is called a ________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
10
You may use a read extraction) as a boolean expression in an if or while statement.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
11
The flag to always show the decimal point in floating numbers is ios:: _________
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
12
The flag to display floating point numbers in non-scientific notation is ios:: _________
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
13
Which command reads one character even if that character is a blank space? ___________
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
14
open is a __________ function of the ofstream and ifstream class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
15
You must use a width statement before each variable that you want output in a certain width
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
16
Streams may be passed to a function.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
17
Using directives can be placed either directly after the include directives, or at the beginning of each function definition.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
18
The manipulator used to change the number of decimal places displayed is _________
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
19
If you use the width command, it stays in effect for all values that are send to the stream.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
20
Two different objects of the same class have a different set of member functions.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
21
In the following function declaration, the istream object cin is called a ___________________.
void outputistream& in=cin);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
22
Which of the following is the correct way to close a file stream named outFile?

A) outFile.close);
B) outFile.close;
C) outFile.close"project.txt");
D) closeoutFile);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
23
To open a file with a user supplied name, you would need to store the name in a variable. If the file name was to have no more than 20 characters in it, which would be an appropriate declaration of the file name variable?

A) char filename;
B) char filename20);
C) char filename[20];
D) char filename[21];
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
24
Which include directive is necessary for file IO

A) #include
B) #include
C) #include
D) #include
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
25
If a file did not open correctly, you should

A) continue on anyway
B) display an error message and continue on
C) display an error message and take some suitable action such as exit
D) exit the program immediately
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
26
After a stream is opened, before it is used for input and output, it should be

A) declared
B) closed
C) checked to see if it opened correctly
D) none of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
27
Which statement correctly opens an input stream named in_file and attaches it to a file name project.txt?

A) in_file=project.txt
B) in_file="project.txt"
C) in_file.open"project.txt");
D) in_file.openproject.txt);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
28
The member function setf stands for

A) set the file name
B) set the flags
C) set the format
D) nothing
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
29
To open an output file and add to the end of the data already in the file you would write

A) outFile.open"project.txt");
B) outFile.append"project.txt");
C) outFile.open"project.txt", append);
D) outFile.open"project.txt", ios::app);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
30
The member function eof) is true/false) when we are ready to read the end of file character.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
31
When is the external name of the file used in the program?

A) Any time you read or write to the file
B) Never
C) Only when reading from the file
D) When opening the file stream
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
32
A __________ is a variable that has functions as well as data associated with it.

A) member
B) int
C) object
D) float
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
33
A function that is associated with an object is called a _________ function.

A) input
B) output
C) member
D) instantiated
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
34
"\n" is a ________ and '\n' is a _______________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
35
In order to read data from a file you

A) must know the kind of data in the file
B) do not need to know the kind of data in the file
C) should prompt the user for the data you are looking for
D) a and c
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
36
Which of the following is not used when using files for input and output

A) Opening the file stream
B) Ensuring that the stream opened
C) Closing the stream
D) Prompting for file data
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
37
The command outFile.precision2);

A) truncates all floating point variables to 2 decimal places
B) sets all output streams in your program to display 2 secimal places
C) displays integers as floating point numbers.
D) displays all floating point values sent to outFile with 2 decimal places.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
38
If the name of the input file was in a variable named filename, which of the following is the correct way to open the input stream named inFile and associate it with this file?

A) inFile.openfilename);
B) inFile=filename;
C) inFile="filename";
D) inFile.open"filename");
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
39
Which of the following is the correct way to determine if a file stream named inFile opened correctly?

A) if inFile.open) )
B) if inFile.fail) )
C) if inFile.opened) )
D) if inFile.failed) )
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
40
The _______ function puts one character back into the input stream.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
41
The get function reads

A) one integer value
B) one float value
C) one double value
D) one character value
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
42
In order to use the stream manipulators, you must include the ______ library

A) manip
B) iomanip
C) cstdlib
D) fstream
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
43
The command outFile.width10) is used to

A) change the number of characters in the output
B) sets the filename of outFile to 10 characters
C) always uses 10 characters to display the output
D) displays the next value in at least 10 characters
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
44
What character will be in variable c after running this code?
Int x;
Char c;
Cin >> x;
Cin)getc);

A) Whatever character is typed by the user
B) Newline
C) Null
D) Blank
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
45
What is wrong with the following code?
While ! fileIn.eof) )
{
FileIn >> value;
FileOut << value;
}

A) We have read past the end of the input file and attempt to output a nonexistent value
B) We have written past the end of the output file
C) Nothing
D) A and B
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
46
We have a file that has a name in it, but the name is written one character per line. We need to write this name to the screen. What is wrong with the following code?
Ifstream fileIn;
FileIn.open"file.txt");
Char ch;
FileIn.getch)
While!fileIn.eof))
{
Cout.putch);
FileIn.getch);
}

A) can not use put with cout.
B) our output has new lines in it.
C) nothing is wrong
D) eof is not a member of an ifstream object
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
47
Which of the following loop condition statements will read all the data in the file assuming that each record in the file is two integer values, and you will read the first one into a variable named intOne, and the other into intTwo?

A) whileinFile >> intOne >> intTwo)
B) whileinFileintOne, intTwo))
C) whileinFile)
D) whileinFile << intOne << intTwo)
E) A and B
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
48
What is the output of the following code?
Char ch='G';
Cout << tolowerch) << endl;

A) G
B) g
C) the integer value of 'g'
D) the integer value of 'G'
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
49
The put function outputs

A) one character value
B) one float value
C) one integer value
D) one double value
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
50
If the user types in the characters 10, and your program reads them into an integer variable, what is the value stored into that integer?

A) 1
B) 0
C) 10
D) none of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
51
ios::showpos is a flag that

A) always displays a + in front of positive integers
B) can be used to find the absolute value of an integer
C) always displays a + in front of all integers
D) all of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
52
Which function returns true if the character argument is a letter?

A) isdigit
B) islower
C) isalpha
D) isspace
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.