Difficulty: Easy
Correct Answer: Correct
Explanation:
Introduction / Context:Nested (or composite) aggregates are common in data modeling. This item checks whether C permits struct-within-struct design, which is frequently used for grouping related fields hierarchically.
Given Data / Assumptions:
Concept / Approach:Standard C allows a struct member to be another struct type by value. This is a straightforward inclusion where the outer struct contains the entire inner struct as a sub-object. Self-embedding by value is not allowed because it would make the size infinite, but nesting different struct types (or the same via pointers) is fine.
Step-by-Step Solution:
1) Define an inner struct type before using it as a member of the outer struct.2) Example: struct Address { int pin; }; struct Person { struct Address addr; int age; };3) This compiles and produces a Person whose layout includes the full Address sub-object.Verification / Alternative check:Compilers handle nested structs routinely; accessing fields uses dot chaining like p.addr.pin.
Why Other Options Are Wrong:
Common Pitfalls:Trying to embed a struct inside itself by value (invalid). Use a pointer for self-reference instead.
Final Answer:Correct
Discussion & Comments