0
0
Cprogramming~10 mins

Nested structures - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a nested structure.

C
struct Point {
    int x;
    int y;
};

struct Rectangle {
    struct Point [1];
    struct Point bottomRight;
};
Drag options to blanks, or click blank then click option'
AtopRight
BtopLeft
Ccorner
Dpoint
Attempts:
3 left
💡 Hint
Common Mistakes
Using a generic name like 'point' instead of a descriptive one.
Forgetting to name the nested struct member.
2fill in blank
medium

Complete the code to access the x coordinate of the topLeft point in a Rectangle variable.

C
struct Rectangle rect;
int x_coord = rect.[1].x;
Drag options to blanks, or click blank then click option'
AtopLeft
Bpoint
CbottomRight
Dcorner
Attempts:
3 left
💡 Hint
Common Mistakes
Accessing bottomRight instead of topLeft.
Trying to access x directly from rect without the nested member.
3fill in blank
hard

Fix the error in the code to correctly initialize a nested structure.

C
struct Rectangle rect = { { [1], 10 }, {20, 30} };
Drag options to blanks, or click blank then click option'
A{5}
BtopLeft
C5
Dx
Attempts:
3 left
💡 Hint
Common Mistakes
Using the member name instead of a value.
Using braces incorrectly around a single integer.
4fill in blank
hard

Fill both blanks to declare and initialize a nested structure variable.

C
struct Rectangle [1] = { {10, [2], {20, 30} };
Drag options to blanks, or click blank then click option'
Arect
B15
C25
Dbox
Attempts:
3 left
💡 Hint
Common Mistakes
Using an invalid variable name.
Confusing the y coordinate value.
5fill in blank
hard

Fill all three blanks to define a nested structure and assign values.

C
struct Point {
    int [1];
    int [2];
};

struct Rectangle {
    struct Point topLeft;
    struct Point [3];
};
Drag options to blanks, or click blank then click option'
Ax
By
CbottomRight
Dcorner
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect member names for Point.
Naming the second Point member incorrectly.