Pages

Sunday, 14 June 2015

CBSE Class 12 - Computer Science - C++ - Board Questions on Header Files

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:

   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)


Q5(CBSE 2011): Which C++ header file(s) will be essentially required to be included to run/execute the following C++ code?

    void main()
 {
    char name[20];
    cin >> name;
    toupper(name[0]);
    cout << name << endl;
 }

Answer: iostream.h (for cin and cout), ctype.h (for toupper)

Q6(CBSE 2009): Write the names of the header files to which the following belong:

    (i) puts()
   (ii) randomize()

Answer:
   (i) stdio.h (puts)
   (ii) stdlib.h (randomize)

Q7(CBSE 2009): Write the names of the header files to which the following belong:
   (i) setw()
  (ii) sqrt()

Answer:
    (i) iomanip.h (setw)
   (ii) math.h (sqrt)

Q8(CBSE 2004): Write the names of the header files to which the following belong:

  (i) sqrt()
  (ii) isalpha()
 (iii) puts()
 (iv) strcpy()

Answer:
  (i)   math.h
  (ii)  ctype.h
  (iii) string.h
  (iv) stdio.h

4 comments:

  1. In question number 8, puts should be in stdio.h and stripy should be in string.h. Not vice versa.

    ReplyDelete
  2. Kal board exam hai poore saal time pass nahi karna chaiye tha lol

    ReplyDelete

We love to hear your thoughts about this post!

Note: only a member of this blog may post a comment.