Languages-C & C Plus Plus [3i Infotech Placement]: Sample Questions 103 - 104 of 354

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 103

Describe in Detail Essay▾

Can we specify variable field width in a scanf () format string? If possible how?

Edit

Explanation

  • It is possible to specify variable field width in a scanf () format string by using % s control string.
  • The % s reads string of variable field width up to the first white space character.

Example:

scanf ( “% s” , name) ; // where name is a character array

  • The scanf () stores results in variables provided in argument list.
  • Note that scanf reads the data from the console or from a FILE stream and parses it.

Question 104

Describe in Detail Essay▾

What is an adaptor class or wrapper class?

Edit

Explanation

  • Adaptor class is a class that has no functionality of its own.
  • Its member functions hide the use of a third party software component or an object with the non-compatible interface or a non- object- oriented implementation.

A wrapper class is a fairly broad concept.

  • It basically means to repackage a piece of code into a new interface (or coating) .
  • Two main reasons for doing a wrapper class are:
    • adapting an interface
    • decoupling the implementation the interface (i.e.. , most often called a “compilation firewall” ) .
Define the Adapter Class Pattern