Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define a structure named Person.
C
struct [1] { char name[50]; int age; };
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase or unrelated names for the structure.
Forgetting to name the structure.
✗ Incorrect
The structure is named Person, so the keyword after struct should be 'Person'.
2fill in blank
mediumComplete the code to declare a variable of the structure type.
C
struct Person [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the structure name as the variable name.
Using uppercase letters at the start of variable names.
✗ Incorrect
The variable name 'person1' is a common and clear choice for a Person structure variable.
3fill in blank
hardFix the error in the structure definition by completing the missing keyword.
C
[1] struct { char name[50]; int age; } Person;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'define' or 'declare' which are not valid keywords here.
Repeating 'struct' unnecessarily.
✗ Incorrect
The 'typedef' keyword is used to create an alias for the structure type.
4fill in blank
hardFill both blanks to define and declare a structure variable with typedef.
C
[1] struct Person { char name[50]; int age; } [2] person1;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'struct' instead of 'typedef' in the first blank.
Using a variable name (like 'person1') instead of the alias name ('Person') in the second blank.
✗ Incorrect
Use 'typedef' to define the structure with alias 'Person' and declare variable 'person1' of that type.
5fill in blank
hardFill all three blanks to create a typedef for struct Person and declare a variable.
C
[1] struct Person { char name[50]; int age; } [2]; [3] p;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'struct' instead of 'typedef' in the first blank.
Using 'struct' instead of the alias in the third blank.
Confusing the alias and variable names.
✗ Incorrect
Use 'typedef' to define the struct, 'Person' as the alias, and then declare variable 'p' of type 'Person'.