package main
import (
"fmt"
"math"
)
func main() {
// Legs of the triangle
a := 7.0
b := 5.0
// Method 1: Using math.Sqrt and math.Pow
h1 := math.Sqrt(math.Pow(a, 2) + math.Pow(b, 2))
fmt.Printf("The hypotenuse (h) is: %.6f\n", h1)
// Method 2: Using direct multiplication
h2 := math.Sqrt(a*a + b*b)
fmt.Printf("The hypotenuse (h) is: %.6f\n", h2)
// Method 3: Using math.Hypot (simple and safe)
h3 := math.Hypot(a, b)
fmt.Printf("The hypotenuse (h) is: %.6f\n", h3)
}
/*
run:
The hypotenuse (h) is: 8.602325
The hypotenuse (h) is: 8.602325
The hypotenuse (h) is: 8.602325
*/