0
0
Cprogramming~10 mins

Array of 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 declare an array of 5 structures named 'students'.

C
struct Student {
    int id;
    char name[50];
};

struct Student [1];
Drag options to blanks, or click blank then click option'
Astudents[5]
Bstudents
CstudentArray
DstudentList[3]
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting the array size.
Using a wrong variable name.
Declaring a single structure instead of an array.
2fill in blank
medium

Complete the code to access the 'id' of the third student in the array.

C
int third_id = students[1].id;
Drag options to blanks, or click blank then click option'
A.2
B[3]
C[2]
D->2
Attempts:
3 left
💡 Hint
Common Mistakes
Using index 3 instead of 2.
Using dot or arrow operators incorrectly.
3fill in blank
hard

Fix the error in the code to assign the name "Alice" to the first student.

C
strcpy(students[1].name, "Alice");
Drag options to blanks, or click blank then click option'
A[1]
B.0
C->0
D[0]
Attempts:
3 left
💡 Hint
Common Mistakes
Using index 1 instead of 0.
Using dot or arrow operators incorrectly.
4fill in blank
hard

Fill both blanks to declare and initialize the second student's id to 102.

C
students[1].id [2] 102;
Drag options to blanks, or click blank then click option'
A[1]
B=
C==
D[0]
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' instead of '='.
Using the wrong index.
5fill in blank
hard

Fill all three blanks to print the name of the last student in the array.

C
printf("%s", students[1].[2]); // Array size is [3]
Drag options to blanks, or click blank then click option'
A[4]
Bname
C5
D[5]
Attempts:
3 left
💡 Hint
Common Mistakes
Using index 5 which is out of bounds.
Using wrong field name.
Confusing array size with last index.