Difficulty: Easy
Correct Answer: An enumeration can be declared with block scope so its effect is local to that block
Explanation:
Introduction / Context:
Enumerations (enum) in C define named integer constants. This question checks understanding of default values, scope, and whether the programmer can control the storage size of enum types directly.
Given Data / Assumptions:
Concept / Approach:
By default, the first enumerator is 0 and subsequent ones increase by 1 unless you explicitly assign values. Enums can be declared at file scope or block scope. The underlying type is implementation-defined; the programmer cannot portably force its size in classic C versions.
Step-by-Step Solution:
1) Check A: C allows explicit assignments but does not require them, so A is wrong.2) Check B: You cannot portably fix enum storage size; B is wrong.3) Check C: Enums can be defined inside a block; the identifiers then have block scope — this is correct.4) Check D: Not all enums are global; scope depends on where they are declared — D is wrong.5) Check E: Default starts from 0, not 1 — E is wrong.
Verification / Alternative check:
Write a small program with an enum inside a function; its identifiers are not visible outside that block.
Why Other Options Are Wrong:
Option A: Explicit assignment is optional.Option B: Underlying type is implementation-defined; no portable direct control.Option D: Scope is not automatically global.Option E: Default start is 0, not 1.
Common Pitfalls:
Assuming enums always start at 1 or thinking they create global names automatically is a frequent misconception.
Final Answer:
An enumeration can be declared with block scope so its effect is local to that block.
Discussion & Comments