How to calculate the surface area of cuboid in Go

1 Answer

0 votes
package main

import "fmt"

// SurfaceAreaCuboid calculates the surface area of a cuboid.
func SurfaceAreaCuboid(length, width, height float64) float64 {
    return 2 * (length*width + width*height + height*length)
}

func main() {
    length := 6.0
    width := 3.0
    height := 4.0

    surfaceArea := SurfaceAreaCuboid(length, width, height)

    fmt.Printf("Surface Area of Cuboid is = %.0f\n", surfaceArea)
}



/*
run:

Surface Area of Cuboid is = 108

*/

 



answered Mar 3 by avibootz
...