0
0
Goprogramming~10 mins

Pointer declaration in Go - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a pointer to an integer variable.

Go
var p [1]int
Drag options to blanks, or click blank then click option'
A*
B&
C&&
D#
Attempts:
3 left
💡 Hint
Common Mistakes
Using & instead of * to declare a pointer type.
Using invalid symbols like && or #.
2fill in blank
medium

Complete the code to assign the address of variable x to pointer p.

Go
p := [1]x
Drag options to blanks, or click blank then click option'
A&
B*
C&&
D#
Attempts:
3 left
💡 Hint
Common Mistakes
Using * instead of & to get the address.
Using invalid symbols like && or #.
3fill in blank
hard

Fix the error in the pointer declaration to correctly declare a pointer to a string.

Go
var strPtr [1]string
Drag options to blanks, or click blank then click option'
A#
B&
C&&
D*
Attempts:
3 left
💡 Hint
Common Mistakes
Using & instead of * in type declaration.
Using invalid symbols like && or #.
4fill in blank
hard

Fill both blanks to declare a pointer to a float64 and assign it the address of variable f.

Go
var ptr [1]float64
ptr = [2]f
Drag options to blanks, or click blank then click option'
A*
B&
C#
D&&
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up * and & operators.
Using invalid symbols like # or &&.
5fill in blank
hard

Fill all three blanks to declare a pointer to an int, assign it the address of n, and then dereference it to get the value.

Go
var p [1]int
p = [2]n
value := [3]p
Drag options to blanks, or click blank then click option'
A*
B&
Cp
D#
Attempts:
3 left
💡 Hint
Common Mistakes
Using & instead of * for pointer declaration or dereferencing.
Using invalid symbols like #.