How to calculate the surface area of a pyramid in Go

1 Answer

0 votes
package main

import (
    "fmt"
    "math"
)

func surfaceAreaOfPyramid(sideLength, height float64) float64 {
    surfaceArea := (sideLength * sideLength) + 2 *
                   (sideLength * math.Sqrt(math.Pow(height, 2) +
                    math.Pow((sideLength/2), 2)))

    return surfaceArea
}

func main() {
    sideLength := 8.0
    height := 14.0

    fmt.Println(surfaceAreaOfPyramid(sideLength, height))
}



/*
run:

296.96351645697655

*/

 



answered Jan 1, 2025 by avibootz

Related questions

1 answer 85 views
1 answer 111 views
1 answer 114 views
1 answer 93 views
1 answer 84 views
1 answer 85 views
...