The control string in C++ consists of three important classifications of…

2014

The control string in C++ consists of three important classifications of characters

  1. A.

    Escape sequence characters, Format specifiers and Whitespace characters

  2. B.

    Special characters, White-space characters and Non-white space characters

  3. C.

    Format specifiers, White-space characters and Non-white space characters

  4. D.

    Special characters, White-space characters and Format specifiers

Attempted by 182 students.

Show answer & explanation

Correct answer: C

Correct classification: Format specifiers, White-space characters and Non-white space characters

  • Format specifiers: directives such as %d, %f, %s that control how values are read or written by formatted I/O functions.

  • White-space characters: characters like space, tab, and newline. In input format strings, whitespace usually matches any amount of whitespace in the input.

  • Non-white-space characters: literal characters (for example commas, letters, symbols) that are not whitespace and must match the input exactly.

How they behave in practice:

  • For formatted input (for example scanf):

    White-space in the format skips any amount of input whitespace; format specifiers read values into variables; non-white-space literals must match the next characters in the input.

  • For formatted output (for example printf):

    Format specifiers produce formatted output for values; white-space and non-white-space characters in the control string are printed as literal characters.

Explore the full course: Mppsc Assistant Professor