Learn about **How to calculate the power of a number in Golang** in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.

Contents

#### How to calculate the power of a number in Golang

```
// Golang program to calculate the power of a number
// using the Pow() function.
package main
import "fmt"
import "math"
func main() {
var num float64 = 10.2
var p float64 =3.0
var result float64 =0
result=math.Pow(num,p)
fmt.Printf("Result : %f",result)
}
```

In the above program, we declare the package main. The main package instructs the Go language compiler that the package must be compiled and an executable file generated. We imported the fmt package, which contains the files of the fmt package, and then we can use a function related to the fmt package. Here, we used the Pow() function of the math package to calculate the power of float number.

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

**Similar Codes :**

How to print the absolute value for an integer number in Golang

How to print the absolute value of float number in Golang