To multiply two numbers in Go, we can simply use the *
operator. Here's an example:
main.go115 chars11 lines
In the code above, we first declare two variables a
and b
, and initialize them with the values 5 and 10 respectively.
We then use the *
operator to multiply the two numbers and assign the result to a new variable c
.
Finally, we print the value of c
to the console using the fmt
package's Println
function, which will output the result 50
.
gistlibby LogSnag