Bird
0
0
DSA Cprogramming~10 mins

Why Arrays Exist and What Problem They Solve in DSA C - Test Your Knowledge

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.

DSA C
int numbers[[1]];
Drag options to blanks, or click blank then click option'
A10
B5
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 named 'data'.

DSA C
int value = data[1];
Drag options to blanks, or click blank then click option'
A[2]
B[1]
C[3]
D[0]
Attempts:
3 left
💡 Hint
Common Mistakes
Using index 3 for the third element, which is actually the fourth element.
Using index 1 which is the second element.
3fill in blank
hard

Fix the error in the code to correctly initialize an array with values 1, 2, 3.

DSA C
int arr[3] = [1]1, 2, 3[2];
Drag options to blanks, or click blank then click option'
A{
B[
C(
D}
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses or square brackets instead of curly braces.
Forgetting to close the initializer with a brace.
4fill in blank
hard

Fill both blanks to create a loop that prints all elements of an array 'arr' of size 4.

DSA C
for(int i = 0; i [1] 4; i[2]) {
    printf("%d\n", arr[i]);
}
Drag options to blanks, or click blank then click option'
A<
B<=
C++
D--
Attempts:
3 left
💡 Hint
Common Mistakes
Using <= 4 causes out-of-bounds access.
Using -- causes an infinite loop.
5fill in blank
hard

Fill all three blanks to declare an array 'scores', assign 10 to the first element, and print it.

DSA C
int scores[3];
scores[1] = [2];
printf("%d", scores[3]);
Drag options to blanks, or click blank then click option'
A[0]
B10
D[1]
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong indices like [1] instead of [0].
Forgetting to assign a value before printing.