Here, We will learn how to get cosine of the radian number in go. We can get it by using Cos() function in math package in go golang.
Function prototype:
func Cos(no float64) float64
Return value:
Cos() function in math package returns
the cosine of the radian number.
Example with code:
package main
import (
"fmt"
"math"
)
func main() {
no := math.Cos(1)
fmt.Printf("%.2f\n", no)
no = math.Cos(0.25)
fmt.Printf("%.2f\n", no)
no = math.Cos(0.75)
fmt.Printf("%.2f\n", no)
no = math.Cos(math.Pi/2)
fmt.Printf("%.2f\n", no)
}
Output:
0.54
0.97
0.73
0.00
To learn more about golang, Please refer given below link:
https://techieindoor.com/go-lang-tutorial/
References:
https://golang.org/doc/
https://golang.org/pkg/