Which of the following is not a valid control structure in Go Lang?
What is the output of the following code snippet?
package main
import "fmt"
func main() {
x := []int{1, 2, 3}
y := &x
(*y)[0] = 4
fmt.Println(x[0])
}
What is the correct syntax for a for loop in Go Lang?
What is the output of the following code snippet?
package main
import "fmt"
func main() {
x := []int{1, 2, 3}
y := &x
z := *y
z[0] = 4
fmt.Println(x[0])
}
What is the output of the following code snippet?
package main
import "fmt"
func main() {
x := 5
y := &x
z := &y
fmt.Println(**z)
}
What is the output of the following code?
package main
import "fmt"
func main() {
a := []int{1, 2, 3, 4, 5}
b := a[1:3]
b[0] = 0
fmt.Println(a)
}
What is the output of the following code snippet?
package main
import "fmt"
func swap(a, b *int) {
temp := *a
*a = *b
*b = temp
}
func main() {
x := 10
y := 20
swap(&x, &y)
fmt.Println(x, y)
}
What will be the output of the following code?
package main
import "fmt"
func main() {
numbers := []int{1, 2, 3, 4, 5}
for i, num := range numbers {
if i == 3 {
continue
}
fmt.Println(num)
}
}
What is the output of the following code snippet?
package main
import "fmt"
func main() {
var ptr *int
if ptr != nil {
fmt.Println("ptr is not nil")
} else {
fmt.Println("ptr is nil")
}
}
What will be the output of the following code?
package main
import "fmt"
func main() {
var x int = 3
var y int = 2
if x > y {
fmt.Println("x is greater than y")
} else if y > x {
fmt.Println("y is greater than x")
}
}