Complete the code to declare an array of 5 integers.
int numbers[[1]];The number inside the brackets specifies the size of the array. Here, 5 means the array can hold 5 integers.
Complete the code to access the third element of the array named 'data'.
int value = data[[1]];Array indexing starts at 0, so the third element is at index 2.
Fix the error in the code to correctly initialize an array with values 1, 2, 3.
int arr[3] = { [1] };
Array initialization requires commas between values inside braces.
Fill both blanks to create a loop that prints all elements of an array named 'arr' of size 'n'.
for (int i = [1]; i [2] n; i++) { printf("%d\n", arr[i]); }
The loop starts at 0 because array indices start at 0. The condition uses < because the last valid index is n-1.
Fill all three blanks to create a function that returns the sum of elements in an integer array.
int sumArray(int arr[], int [1]) { int sum = 0; for (int i = 0; i [2] [3]; i++) { sum += arr[i]; } return sum; }
The function takes the array size as 'size'. The loop runs while i < size to avoid out-of-bounds access.
