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 variable name, then the type. The equal sign = is not used here; instead, you just write the type after the variable name. So the correct syntax is var numbers [5]int.
Complete the code to declare and initialize an array of 3 strings.
var fruits = [1]string{"apple", "banana", "cherry"}
To declare and initialize an array of 3 strings, you specify the size in square brackets before the type, like [3]string. This tells Go the array has exactly 3 elements.
Fix the error in the array declaration to create an array of 4 floats.
var values = [1]float64{1.1, 2.2, 3.3, 4.4}
Arrays in Go require the size inside square brackets before the type. So [4]float64 declares an array of 4 floats. Using []float64 would declare a slice, which is different.
Fill the blank to declare an array of 2 booleans and initialize it with true and false.
var flags [1]bool = {true, false}The array size must be specified as [2] before the type. The initialization uses curly braces {} with the values inside. So the correct declaration is var flags [2]bool = {true, false}.
Fill both blanks to declare and initialize an array of 3 integers with values 10, 20, and 30.
var nums [1]int = [2]
The array size must be [3] before the type. The initialization uses curly braces with the values inside. The correct initialization is {10, 20, 30}. The extra option {10, 20, 30, 40} is a distractor and should not be used.