Match the following with respect to C++ data types : List – I List – II a.…

2012

Match the following with respect to C++ data types :

List – I

List – II

a. User defined type

1. Qualifier

b. Built-in type

2. Union

c. Derived type

3. Void

d. Long double

4. Pointer

Code :

a

b

c

d

Answer: A. 2 3 4 1Concept. C++ sorts every type into one of three families. Fundamental (built-in) types are supplied by the language itself — int, char, float, double, bool…

  1. A.

    2

    3

    4

    1

  2. B.

    3

    1

    4

    2

  3. C.

    4

    1

    2

    3

  4. D.

    3

    4

    1

    2

Attempted by 17 students.

Show answer & explanation

Correct answer: A

Concept. C++ sorts every type into one of three families. Fundamental (built-in) types are supplied by the language itself — int, char, float, double, bool and void. Derived types are built out of an already existing type and declare no members of their own — arrays, pointers, references and functions. User-defined types are declared by the programmer together with their own members — class, struct, union and enum. Alongside these families C++ has keywords that are written in front of a base type instead of naming a type by themselves: the size/sign specifiers signed, unsigned, short and long, and the cv-qualifiers const and volatile. Classic exam textbooks gather all of these under the single heading "qualifier", and it is that broader sense this item uses.

Application to this item.

  1. a. User defined type — a union is written by the programmer with its own member list, exactly as a class, struct or enum is, so it falls in the user-defined family. So a takes 2.

  2. b. Built-in type — void is defined by the language, not by the programmer; it names "no value" for a function return type and yields the generic pointer type void*. So b takes 3.

  3. c. Derived type — a pointer type T* is constructed from an existing type T and introduces no new members, which is exactly the definition of a derived type (arrays, references and functions are derived for the same reason). So c takes 4.

  4. d. Long double — the question here is which heading the word long belongs under. It is written in front of the base type double as a size specifier, so on this taxonomy the entry sits under the qualifier heading rather than under the user-defined or derived families. (Strictly, the C++ standard counts long double itself among the fundamental floating-point types; the exam’s List-II simply has no "fundamental type" slot left, because void already occupies it.) So d takes 1.

Cross-check.

  • A union cannot be a derived type: a derived type adds no members of its own, while a union declares its members.

  • Void cannot be user-defined: no programmer declaration brings it into existence — the language defines it.

  • The exam taxonomy reads the long component of long double as a size specifier applied to the base type double, and files it under its broad qualifier heading — not as a member-declaring type like a union, not as a type constructed from another type like a pointer, and not as a language-supplied fundamental name like void. (Written on its own long is still a valid type specifier: long x; declares a long int.)

  • Each of 1, 2, 3 and 4 is consumed exactly once, so the code has to be a rearrangement of all four numbers.

Result.

List – I entry

Matches

a. User defined type

2. Union

b. Built-in type

3. Void

c. Derived type

4. Pointer

d. Long double

1. Qualifier

Read in the order a b c d, the code is 2 3 4 1.

Explore the full course: Nta Ugc Net Paper 2

Loading lesson…