input output stream Flashcards

1
Q

What is the header of cin and cout

A
// 
#include
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How to display string of binary 10 digit value 7 in decimal

A

std: :bitset<10> value(7);
std: :cout &laquo_space;value;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What std function to read one line of string from input stream?

A

std::getline
Ex:
std::string input;
std::getline(cin, input);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the simple way to read input data until end of file?

A

string input_data;
while ( !cin.eof() ) {
getline( cin, input_data);
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How to tell cout to display true or false instead of 0 or 1?

A

cout &laquo_space;boolalpha;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Show how to use stringstream for input stream.

A
#include 
...
stringstream sin( "123456\n"
                             "xxxyes\n"
                           )
string line;
getline(sin, line);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How to display double in two decimal precision

A

cout &laquo_space;std::fixed &laquo_space;setprecision(2); &laquo_space;value;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly