Bird
0
0
DSA Cprogramming~10 mins

Arrays vs Other Data Structures When to Choose Arrays in DSA C - Interactive Comparison 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 integers.

DSA C
int numbers[[1]];
Drag options to blanks, or click blank then click option'
A10
B0
C5
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using zero or negative numbers as size
Forgetting the size inside brackets
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'
A0
B3
C1
D2
Attempts:
3 left
💡 Hint
Common Mistakes
Using 3 instead of 2 for the third element
Confusing 1-based indexing
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] };
Drag options to blanks, or click blank then click option'
A1, 2, 3
B1. 2. 3.
C1 2 3
D1; 2; 3
Attempts:
3 left
💡 Hint
Common Mistakes
Using semicolons instead of commas
Missing commas between values
4fill in blank
hard

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

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

Fill all three blanks to create a function that returns the sum of elements in an integer array.

DSA C
int sumArray(int arr[], int [1]) {
    int sum = 0;
    for (int i = 0; i [2] [3]; i++) {
        sum += arr[i];
    }
    return sum;
}
Drag options to blanks, or click blank then click option'
Asize
B<
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using <= causing out-of-bounds
Not passing array size as parameter