Difficulty: Easy
Correct Answer: iostream.h
Explanation:
Introduction / Context:
Modern C++ uses header names without the .h
suffix, such as
. However, many legacy multiple-choice questions still cite pre-standard headers. Among the given choices, one classic header historically declared both cin
and cout
together.
Given Data / Assumptions:
cin
and cout
are standard input/output stream objects.
Concept / Approach:
Historically, the header <iostream.h>
(pre-Standard C++) declared stream classes and the global objects cin
, cout
, cerr
, and clog
. Modern C++ replaces it with <iostream>
in namespace std
. Separate headers like <istream.h>
and <ostream.h>
were compiler-specific and are not part of the current standard. Given the provided choices, the correct legacy answer is iostream.h
.
Step-by-Step Solution:
iostream.h
, the combined header. 3) Note that modern code should prefer #include <iostream>
and std::cout
/std::cin
. 4) Remember that manipulators like <iomanip>
are separate in both eras.
Verification / Alternative check:
Compiling legacy examples against old compilers required <iostream.h>
. On conforming modern compilers, <iostream.h>
is absent; use <iostream>
instead (but that is not among the options here).
Why Other Options Are Wrong:
istream.h
and ostream.h
: non-standard, often partial; not both together.
iomanip.h
: for formatting manipulators, not for defining cin
/cout
.
Common Pitfalls:
<iostream>
(no .h) and namespace std
.
Final Answer:
iostream.h
Discussion & Comments