Complete the code to declare an array of 5 integers.
[1] numbers [5]int
In Go, to declare an array variable, you use var followed by the name, then the type. Just var numbers [5]int is correct. Here, the blank is for the declaration keyword, so the correct answer is var.
Complete the code to assign the value 10 to the first element of the array.
numbers[[1]] = 10
Arrays in Go are zero-indexed, which means the first element is at index 0. So to assign 10 to the first element, use numbers[0] = 10.
Fix the error in the code to print the length of the array.
fmt.Println(len([1]))
The len function in Go takes the array variable directly without parentheses. So len(numbers) is correct, but inside fmt.Println you just pass len(numbers). Here, the blank is for the argument inside len(), so it should be numbers.
Fill both blanks to create an array of 3 strings and assign a value to the second element.
[1] fruits [3]string fruits[[2]] = "Apple"
To declare an array in Go, use var followed by the variable name and type. The second element of an array is at index 1 because indexing starts at 0.
Fill all three blanks to create an array, assign values, and print the last element.
[1] scores [4]int scores[0] = 90 scores[[2]] = 85 fmt.Println(scores[[3]])
Declare the array with var. The second assignment is to index 1 (second element). The last element in an array of size 4 is at index 3.