To find the area of a trapezoid in go programming language, the formula to be used is:
main.go21 chars2 lines
where b1
and b2
are the lengths of the parallel bases, and h
is the height (the perpendicular distance between the bases).
Here is a go function that takes in the values of b1
, b2
, and h
, and returns the area of the trapezoid:
main.go96 chars5 lines
You can call this function with the appropriate values and it will return the area of the trapezoid.
Here is an example usage:
main.go168 chars12 lines
gistlibby LogSnag