Bird
0
0
DSA Cprogramming~10 mins

Array Access and Update at 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 access the element at index 2 in the array.

DSA C
int arr[] = {10, 20, 30, 40, 50};
int value = arr[[1]];
printf("%d\n", value);
Drag options to blanks, or click blank then click option'
A2
B3
C1
D4
Attempts:
3 left
💡 Hint
Common Mistakes
Using index 3 or 4 which accesses wrong elements.
Forgetting that array indexes start at 0.
2fill in blank
medium

Complete the code to update the element at index 1 to 100.

DSA C
int arr[] = {5, 10, 15, 20};
arr[[1]] = 100;
printf("%d\n", arr[1]);
Drag options to blanks, or click blank then click option'
A2
B0
C3
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Updating the wrong index like 0 or 2.
Confusing index with the value.
3fill in blank
hard

Fix the error in the code to correctly update the last element of the array.

DSA C
int arr[] = {1, 2, 3, 4, 5};
int n = 5;
arr[[1]] = 50;
printf("%d\n", arr[4]);
Drag options to blanks, or click blank then click option'
A5
Bn - 1
C4
Dn
Attempts:
3 left
💡 Hint
Common Mistakes
Using n as index which is out of bounds.
Using 5 as index which is invalid.
4fill in blank
hard

Fill both blanks to print the updated value at index 3 after setting it to 99.

DSA C
int arr[] = {7, 8, 9, 10, 11};
arr[[1]] = 99;
printf("%d\n", arr[[2]]);
Drag options to blanks, or click blank then click option'
A3
B4
C2
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using different indexes for update and print.
Using out of range indexes.
5fill in blank
hard

Fill all three blanks to update the element at index 0 to 42, then print it.

DSA C
int arr[] = {0, 1, 2, 3};
arr[[1]] = [2];
printf("%d\n", arr[[3]]);
Drag options to blanks, or click blank then click option'
A0
B42
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong index for update or print.
Using wrong value for update.