Complete the code to declare an array of integers with size 5.
int[] numbers = new int[[1]];The array size must be specified as 5 to create an array that can hold 5 integers.
Complete the code to access the third element in the array named 'items'.
var thirdItem = items[[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 = new int[] { [1] };Array initialization requires comma-separated values inside curly braces.
Fill both blanks to create a loop that prints all elements of an array named 'data'.
for (int i = [1]; i [2] data.Length; i++) { Console.WriteLine(data[i]); }
The loop starts at index 0 and runs while i is less than data.Length to avoid out-of-bounds errors.
Fill all three blanks to create a method that returns the sum of all elements in an integer array 'nums'.
public int SumArray(int[] nums) {
int sum = [1];
foreach (int [2] in nums) {
sum [3] num;
}
return sum;
}Initialize sum to 0, use 'num' as the loop variable, and add each num to sum using '+='.
