Complete the code to access the element at index 2 in the array.
arr := [5]int{10, 20, 30, 40, 50} value := arr[[1]] fmt.Println(value)
The index 2 accesses the third element in the array, which is 30.
Complete the code to update the element at index 1 to 100.
arr := [3]int{5, 10, 15} arr[[1]] = 100 fmt.Println(arr)
Index 1 is the second element, which we update to 100.
Fix the error in the code to correctly update the last element of the array.
arr := [4]int{1, 2, 3, 4} arr[[1]] = 10 fmt.Println(arr)
The last element of an array with length 4 is at index 3.
Fill both blanks to access and update the middle element of the array.
arr := [5]int{10, 20, 30, 40, 50} arr[[1]] = arr[[2]] + 5 fmt.Println(arr)
The middle element in an array of length 5 is at index 2. We update it by adding 5 to its current value.
Fill all three blanks to double the first element, set the last element to 0, and print the array.
arr := [4]int{2, 4, 6, 8} arr[[1]] = arr[[2]] * 2 arr[[3]] = 0 fmt.Println(arr)
We double the first element at index 0, then set the last element at index 3 to 0.
