Machine-translated by Google. Questions are authored in English.
Top

Streams and File IO Questions and Answers

1.

EXTRACTION operator >> ignores the following

Exam Year(s)

Tripura Public Service Commission - 2026,

Answer: C

The extraction operator ignores WHITESPACE.

In C++ the stream extraction operator >> skips leading whitespace (blanks, tabs and newlines) before reading a value, because the skipws flag is set by default. That is why cin >> a >> b reads two numbers typed on separate lines, and why it cannot read a string containing spaces.

Integers and floats are the data it reads, not skips. Comments are removed by the compiler from source code; they never appear in an input stream.

Please log in or register to report this question.

2.

Which of the following mode declaration is used in C++ to open a file for input ?

Exam Year(s)

UGC NET - 2012,

Answer: D

The mode ios::in is used in C++ to open a file for input (reading). It is passed to the open function of the file stream, as in ifstream.open(name, ios::in).

ios::app opens a file for output in append mode. 'in::ios' reverses the class and the mode and is not valid, and ios::file is not a file mode. So only ios::in is right.

Please log in or register to report this question.

Loading…

Other Subjects

Tags: Streams and File IO Questions and Answers || Streams and File IO MCQ Questions and Answers || Streams and File IO GK Questions and Answers || Streams and File IO GK MCQ Questions || Streams and File IO Multiple Choice Questions and Answers || Streams and File IO GK || GK on Streams and File IO || Object Oriented Programming Questions and Answers || Object Oriented Programming MCQ Questions and Answers || Object Oriented Programming GK Questions and Answers || GK on Object Oriented Programming