Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different name than Person.
Forgetting to write struct before the name.
✗ Incorrect
The structure name is Person as required.
2fill in blank
mediumComplete the code to create a variable of type Person.
C
struct Person [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a name not matching the example.
Omitting the semicolon.
✗ Incorrect
The variable name person is used to create a Person instance.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a plural form like ages.
Capitalizing the first letter incorrectly.
✗ Incorrect
The member name is age exactly as declared in the structure.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect member names like Name or years.
Assigning string directly to char array without strcpy.
✗ Incorrect
The name member is a string, so we use strcpy to copy "John".
The age member is an integer and assigned 30.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong structure or variable names.
Mixing member names.
✗ Incorrect
The structure is named Person, the string member is name, and the variable declared is person1.