To divide two numbers in Go, use the /
operator. Here's an example:
main.go112 chars15 lines
In the example above, we declare two variables a
and b
and assign them the values of 10
and 2
respectively. We then use the /
operator to perform the division operation and assign the result to a new variable c
. Finally, we print out the value of c
which is expected to be 5
.
gistlibby LogSnag