Complete the code to declare a function that takes an integer value.
func increment([1] int) int { return [1] + 1 }
The function parameter should be a simple variable name without pointer symbols to pass by value.
Complete the code to declare a function that takes a pointer to an integer.
func incrementPointer([1] *int) { *[1] = *[1] + 1 }
The parameter name can be any valid identifier; here, 'num' is used consistently.
Fix the error in the code to correctly modify the original variable using a pointer.
func main() {
x := 5
incrementPointer([1]x)
fmt.Println(x)
}To pass the address of x, use the & operator before x.
Fill both blanks to create a function that swaps two integers using pointers.
func swap([1] *int, [2] *int) { temp := *a *a = *b *b = temp }
The function parameters should be pointer variables named 'a' and 'b' to match the function body.
Fill all three blanks to call the swap function correctly in main.
func main() {
x, y := 3, 4
swap([1][2], [3]y)
fmt.Println(x, y)
}Use &x and &y to pass pointers to the swap function. The comma separates arguments.