Difficulty: Easy
Correct Answer: int length;
Explanation:
Introduction / Context:
Correctly forming declarations is foundational in C. A declaration must present a valid type specifier sequence followed by one or more declarators (identifiers, possibly with pointers, arrays, or function forms).
Given Data / Assumptions:
Concept / Approach:
Valid type specifiers can be combined in restricted ways (e.g., long int is valid, but int long; without an identifier is incomplete). A declaration also requires an identifier unless it is a typedef or a function prototype. Here, only “int length;” supplies both a valid type and an identifier.
Step-by-Step Solution:
Option (a): type int and identifier length → valid object declaration.Option (b): “char int;” mixes two base types and lacks an identifier → invalid.Option (c): “int long;” reversed order without identifier; even “long int;” would still lack an identifier → invalid.Option (d): “float double;” two base types together, no identifier → invalid.Option (e): “long signed;” incompatible specifier sequence and no identifier → invalid.
Verification / Alternative check:
Compilers accept (a) but reject the others with messages about expected identifiers or invalid type specifiers.
Why Other Options Are Wrong:
They either combine incompatible base types or omit an identifier, violating declaration syntax.
Common Pitfalls:
Providing only a type without an identifier; mixing multiple base types that cannot appear together.
Final Answer:
int length;
Discussion & Comments