Go program to find Square root of a Number

This Go program to find the Square root of a Number uses the built-in math sqrt function on the user given value.

package main

import (
    "fmt"
    "math"
)

func main() {

    var sqrtnum, sqrtOut float64

    fmt.Print("\nEnter the Number to find Square Root = ")
    fmt.Scanln(&sqrtnum)

    sqrtOut = math.Sqrt(sqrtnum)

    fmt.Println("\nThe Square of a Given Number  = ", sqrtOut)
}
SureshMac:GoExamples suresh$ go run squareroot1.go

Enter the Number to find Square Root = 64

The Square of a Given Number  =  8
SureshMac:GoExamples suresh$ go run squareroot1.go

Enter the Number to find Square Root = 82

The Square of a Given Number  =  9.055385138137417

Golang program to find Square root of a Number

This golang program uses the math pow function to calculate the square root of the given number.

package main

import (
    "fmt"
    "math"
)

func main() {

    var sqrtnum, sqrtOut float64

    fmt.Print("\nEnter the Number to find Square Root = ")
    fmt.Scanln(&sqrtnum)

    sqrtOut = math.Pow(sqrtnum, 0.5)

    fmt.Println("\nThe Square of a Given Number  = ", sqrtOut)
}
Golang program to find Square root of a Number 2