Write a Go Program to find the Volume and Surface Area of a Cone. The math formula to find the cone volume, surface area, and lateral surface area are
- Cone Surface Area = πrl + πr² (l = length, r = radius)
- Volume of a Cone = 1/3 πr²h ( h = Cone height)
- The Lateral Surface Area of a Cone = πrl
package main
import (
"fmt"
"math"
)
func main() {
var cnRadius, cnHeight, cnSA, cnVol, cnLSA, cnLen float64
fmt.Print("Enter the Cone Radius = ")
fmt.Scanln(&cnRadius)
fmt.Print("Enter the Cone Height = ")
fmt.Scanln(&cnHeight)
cnLen = math.Sqrt(cnRadius*cnRadius + cnHeight*cnHeight)
cnSA = math.Pi * cnRadius * (cnRadius + cnLen)
cnVol = (1.0 / 3) * math.Pi * cnRadius * cnRadius * cnHeight
cnLSA = math.Pi * cnRadius * cnLen
fmt.Println("The Length of a Cone Side (Slant) = ", cnLen)
fmt.Println("The Volume of a Cone = ", cnVol)
fmt.Println("The Surface Area of a Cone = ", cnSA)
fmt.Println("The Lateral Surface Area of a Cone = ", cnLSA)
}
