Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a size different than 5.
Forgetting to specify the size.
✗ Incorrect
The array size should be 5 to hold 5 elements.
2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong size number.
Using floating point division instead of integer.
✗ Incorrect
The middle index is size divided by 2, so 5 / 2 = 2 (integer division).
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Starting loop at mid + 1 causes skipping the middle element.
Starting loop at 0 shifts all elements unnecessarily.
✗ Incorrect
We start shifting from the middle index to make space for the new element.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Inserting at wrong index.
Not updating the size after insertion.
✗ Incorrect
Insert at middle index and increase size by 1 after insertion.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong start or end index.
Using decrement instead of increment in loop.
✗ Incorrect
Start from 0, go to n (size), and increment i to print all elements.
