The Go code is below.
Error Message: syntax error: unexpected float64 at end of statement in line 9.
package main
import (
"fmt"
"math"
)
func pow(x, n, lim float64) float64 {
v float64 = math.Pow(x,n) // line 9
if v<lim {
return v
} else {
fmt.Printf("%g >= %g\n", v, lim)
}
return lim
}
func main() {
fmt.Println(
pow(3, 2, 10),
pow(3, 2, 20),
)
}
I don't know what is wrong. Who know that?
Change line 9 to either of statements below:
v := math.Pow(x,n) // implicit type declaration and assignment
or
var v float64 = math.Pow(x,n) // explicit type declaration and assignment
See short variable declarations.
Variable declaration in Go
static var var_name data_type = value
or
dynamic: var_name := value
In your case at line 9 you have missed both standard
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With