Bird
0
0
DSA Cprogramming~10 mins

Array Insertion at Middle Index in DSA C - Interactive 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 of size 5.

DSA C
int arr[[1]];
Drag options to blanks, or click blank then click option'
A7
B10
C3
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Using a size different than 5.
Forgetting to specify the size.
2fill in blank
medium

Complete the code to find the middle index of the array of size 5.

DSA C
int mid = [1] / 2;
Drag options to blanks, or click blank then click option'
A6
B5
C4
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong size number.
Using floating point division instead of integer.
3fill in blank
hard

Fix the error in the loop that shifts elements to the right before insertion.

DSA C
for (int i = n - 1; i >= [1]; i--) {
    arr[i + 1] = arr[i];
}
Drag options to blanks, or click blank then click option'
Amid
B0
Cmid + 1
Dn
Attempts:
3 left
💡 Hint
Common Mistakes
Starting loop at mid + 1 causes skipping the middle element.
Starting loop at 0 shifts all elements unnecessarily.
4fill in blank
hard

Fill both blanks to insert a new value at the middle index and update the size.

DSA C
arr[[1]] = new_value;
n = [2];
Drag options to blanks, or click blank then click option'
Amid
Bn + 1
Cn - 1
Dmid + 1
Attempts:
3 left
💡 Hint
Common Mistakes
Inserting at wrong index.
Not updating the size after insertion.
5fill in blank
hard

Fill all three blanks to print the array elements after insertion.

DSA C
for (int i = [1]; i < [2]; i[3]) {
    printf("%d ", arr[i]);
}
Drag options to blanks, or click blank then click option'
A0
Bn
C++i
D--i
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong start or end index.
Using decrement instead of increment in loop.