Trigonometry with Go Language - Sin, Cos, Tan Functions Examples
Package math provides functions to calculate Trigonometric functions values. Program to demonstrate how to calculate Trigonometric functions values in Go, package main import ( "fmt" "math" ) func main() { var degrees float64 fmt.Println( "Enter value of angle in degrees : " ) _, err := fmt.Scanf( "%f" , °rees) if err != nil { fmt.Println(err) } //calculate the sine s := math.Sin(degrees) fmt.Println( "The Sine of " , degrees, " degrees is : " , s) //calculate the cosine c := math.Cos(degrees) fmt.Println( "The Cosine of " , degrees, " degrees is : " , c) //calculate the tan t := math.Tan(degrees) fmt.Println( "The Tangent of " , degrees, " degrees is : " , t) //calculate the sec se := 1 / math.Sin(degrees) fmt.Println( "The Sec of " , degrees, " degrees is : " , se)