0
0
Cprogramming~10 mins

One-dimensional arrays in C - 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 integer array named numbers with 5 elements.

C
int [1][5];
Drag options to blanks, or click blank then click option'
Anumbers
Bnum
Carray
Dlist
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name different from 'numbers'.
Forgetting the array size in the declaration.
2fill in blank
medium

Complete the code to assign the value 10 to the third element of the array numbers.

C
numbers[[1]] = 10;
Drag options to blanks, or click blank then click option'
A1
B2
C3
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using 3 as the index which is actually the fourth element.
Using 1 which is the second element.
3fill in blank
hard

Fix the error in the code to correctly print the first element of the array numbers.

C
printf("%d", numbers[1]);
Drag options to blanks, or click blank then click option'
A[1]
B(0)
C[0]
D(1)
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses instead of square brackets.
Using index 1 instead of 0.
4fill in blank
hard

Fill both blanks to create a loop that prints all elements of the array numbers of size 5.

C
for(int [1] = 0; [2] < 5; [1]++) {
    printf("%d\n", numbers[[1]]);
}
Drag options to blanks, or click blank then click option'
Ai
Bj
Ccount
Dindex
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names in the loop parts.
Using a variable name not matching the one in the printf statement.
5fill in blank
hard

Fill all three blanks to declare, initialize, and print the first element of an integer array arr with values 1, 2, 3.

C
int [1][] = [2];
printf("%d", [3][0]);
Drag options to blanks, or click blank then click option'
Aarr
B{1, 2, 3}
Cnumbers
D{3, 2, 1}
Attempts:
3 left
💡 Hint
Common Mistakes
Using different names for the array in declaration and print.
Incorrect array initialization syntax.