Go language program to take a number as input and calculate the square root of given number
Following program shows you how to take a number as input and calculate the square root of given number.
In this program we get input from user and calculate square root using math.Sqrt()
method
package main
import "fmt"
import "math"
func main() {
var input float64
var result float64
fmt.Println("Please enter a number:")
fmt.Scanf("%f", &input)
result = math.Sqrt(input)
fmt.Println("Square root of " , input , " is: " , result)
}
Output:
Please enter a number:
16
Square root of 16 is: 4