Complete the code to declare an array of 5 integers.
var numbers [5]int = [1]
The correct way to initialize an array with values in Go is using the syntax [size]type{values}. Here, [5]int{1, 2, 3, 4, 5} creates an array of 5 integers.
Complete the code to declare an array of 3 strings with default zero values.
var fruits [1]To declare an array of 3 strings in Go, use [3]string. This creates an array with 3 elements, each initialized to the zero value for strings (empty string).
Fix the error in the array initialization syntax.
var primes = [1]int{2, 3, 5, 7, 11}
The correct syntax to initialize an array is [size]type{values}. Here, [5]int{2, 3, 5, 7, 11} creates an array of 5 integers.
Fill both blanks to create an array of 4 floats initialized with values.
var scores [1] = [2]{98.5, 87.0, 92.3, 88.8}}
The declaration var scores [4]float64 = [4]{98.5, 87.0, 92.3, 88.8} is almost correct except the second blank should be [4] to specify the array size before the values. This fully defines an array of 4 float64 values.
Fill all three blanks to declare and initialize an array of 3 booleans with true, false, true.
var flags [1] = [2][3]
The correct declaration is var flags [3]bool = [3]{true, false, true}. The first blank is the type with size, the second blank is the size in square brackets for the value, and the third blank is the list of boolean values inside curly braces.