0
0
Cprogramming~10 mins

Why arrays are needed in C - 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 an array of 5 integers.

C
int numbers[[1]];
Drag options to blanks, or click blank then click option'
A5
B10
C0
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using zero as the size, which creates an empty array.
Forgetting to specify the size.
2fill in blank
medium

Complete the code to access the third element of the array.

C
int third = numbers[[1]];
Drag options to blanks, or click blank then click option'
A2
B3
C1
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using 3 as the index, which is actually the fourth element.
Confusing 1-based and 0-based indexing.
3fill in blank
hard

Fix the error in the code to initialize an array with values 1 to 5.

C
int numbers[5] = {1, 2, 3, 4, [1];
Drag options to blanks, or click blank then click option'
A4
B5
C6
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using a number outside the intended range.
Repeating a previous number.
4fill in blank
hard

Fill both blanks to create an array of 4 floats and assign 3.14 to the first element.

C
float [1][[2]];
[1][0] = 3.14;
Drag options to blanks, or click blank then click option'
Avalues
Bnumbers
C4
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Using a size that does not match the intended number of elements.
Using an invalid variable name.
5fill in blank
hard

Fill all three blanks to declare an integer array named 'scores' of size 3 and assign 100 to the last element.

C
int [1][[2]];
[1][[3]] = 100;
Drag options to blanks, or click blank then click option'
Ascores
B3
C2
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong index for the last element.
Mismatch between array size and index.