EXTRACTION operator >> ignores the following
2026
EXTRACTION operator >> ignores the following
- A.
INTEGER
- B.
FLOAT
- C.
WHITESPACE
- D.
COMMENTS
Attempted by 111 students.
Show answer & explanation
Correct answer: C
The extraction operator (>>) in C++ is designed to read formatted input from a stream, such as cin. When reading data into variables like integers or floats, the operator automatically skips over leading whitespace characters, including spaces, tabs, and newlines. This behavior ensures that the program can correctly identify the start of a numeric or string value even if there are extra spaces before it. Therefore, WHITESPACE is the correct answer because the operator explicitly ignores these characters to locate valid data. In contrast, INTEGER and FLOAT are the actual types of data that the operator attempts to extract and store, not ignore. While comments are ignored by the compiler during preprocessing, they are not a runtime concern for the extraction operator itself. Understanding this distinction is crucial for mastering input handling in C++.