Recall & Review
beginner
What is a nested structure in C?
A nested structure is a structure that contains another structure as one of its members. It helps organize related data in a clear way.
Click to reveal answer
beginner
How do you access a member of a nested structure in C?
You use the dot operator (.) for normal structures and the arrow operator (->) for pointers. For nested structures, you chain these operators, like
outer.inner.member.Click to reveal answer
intermediate
Why use nested structures instead of separate structures?
Nested structures group related data together inside a bigger structure. This makes the code easier to read and maintain, like putting related tools in one toolbox.
Click to reveal answer
beginner
Example: Define a structure
Address with city and zip, then a structure Person with name and Address nested inside.struct Address {
char city[50];
int zip;
};
struct Person {
char name[50];
struct Address address;
};
Click to reveal answer
intermediate
How do you initialize a nested structure in C?
You can initialize nested structures by listing values in order, like
struct Person p = {"Alice", {"New York", 10001}};.Click to reveal answer
Which operator is used to access a member of a nested structure variable in C?
✗ Incorrect
Use dot (.) when you have a structure variable, and arrow (->) when you have a pointer to a structure.
What is the correct way to define a nested structure in C?
✗ Incorrect
You must specify the keyword 'struct' before the nested structure type name.
Given
struct Person { char name[20]; struct Address addr; };, how do you access the city of a Person variable p?✗ Incorrect
Use dot operator to access nested members: first p.addr then city.
Why might you use nested structures in a program?
✗ Incorrect
Nested structures help organize related data logically, improving code clarity.
How do you initialize a nested structure in C?
✗ Incorrect
Nested braces initialize the nested structure inside the outer structure.
Explain what nested structures are and how you access their members in C.
Think about how you open a box inside another box to get an item.
You got /3 concepts.
Describe how to define and initialize a nested structure with an example.
Imagine filling out a form with sections inside sections.
You got /3 concepts.