Board Questions On Header Files
There is 1 or 2 Marks questions based on function mapping to header files
Q1(CBSE 2012): Write the names of the header file to which of the following belong:
(i) sqrt( )
(ii) randomize()
Answer: (i) math.h
(ii) stdlib.h
Q2: Name the header file that will be needed for the following code:
Answer: iostream.h (for cout), iomanip.h (for setw)
Q3(CBSE 2012): Which C++ header file(s) are especially required to be included to run the following C++ code. (Note: Do not include any header which is/are not required):
Answer: iostream.h (for cout), string.h (for strlen)
Q4(CBSE 2013): Observe the following C++ code and write name(s) of the header file(s) which will be essentially required to run in a C++ compiler:
Answer: iostream.h (for cin, cout), math.h (for abs)
(i) sqrt( )
(ii) randomize()
Answer: (i) math.h
(ii) stdlib.h
Q2: Name the header file that will be needed for the following code:
void main() { char word [] = "Board Examination"; cout << setw(20) << word; }
Answer: iostream.h (for cout), iomanip.h (for setw)
Q3(CBSE 2012): Which C++ header file(s) are especially required to be included to run the following C++ code. (Note: Do not include any header which is/are not required):
void main() { char TEXT[] = "something"; cout << "Remaining SMS chars: " << 160 - strlen(TEXT) << endl; }
Answer: iostream.h (for cout), string.h (for strlen)
Q4(CBSE 2013): Observe the following C++ code and write name(s) of the header file(s) which will be essentially required to run in a C++ compiler:
void main() { int number; cin >> number; if (abs(number) == number) cout << "positive" << endl; }
Answer: iostream.h (for cin, cout), math.h (for abs)