0
0
Cprogramming~10 mins

Why structures are needed - Test Your Understanding

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

Complete the code to declare a structure named Person.

C
struct [1] {
    char name[50];
    int age;
};
Drag options to blanks, or click blank then click option'
APerson
BEmployee
CData
DStudent
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different name than Person.
Forgetting to write struct before the name.
2fill in blank
medium

Complete the code to create a variable of type Person.

C
struct Person [1];
Drag options to blanks, or click blank then click option'
Adata
Bp1
Cperson
Dperson1
Attempts:
3 left
💡 Hint
Common Mistakes
Using a name not matching the example.
Omitting the semicolon.
3fill in blank
hard

Fix the error in accessing the age member of the structure variable.

C
person.[1] = 25;
Drag options to blanks, or click blank then click option'
Aage
Bages
CAge
DpersonAge
Attempts:
3 left
💡 Hint
Common Mistakes
Using a plural form like ages.
Capitalizing the first letter incorrectly.
4fill in blank
hard

Fill both blanks to initialize the name and age members of the structure variable.

C
strcpy(person.[1], "John");
person.[2] = 30;
Drag options to blanks, or click blank then click option'
Aname
Bage
CName
Dyears
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect member names like Name or years.
Assigning string directly to char array without strcpy.
5fill in blank
hard

Fill all three blanks to create a structure, declare a variable, and assign values.

C
struct [1] {
    char [2][50];
    int age;
};

struct Person [3];
Drag options to blanks, or click blank then click option'
APerson
Bname
Cperson1
Dage
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong structure or variable names.
Mixing member names.