find the area of a triangle in go

To find the area of a triangle in Go, you can use the following formula:

main.go
area = 0.5 * base * height
27 chars
2 lines

In Go, the code to find the area of a triangle could look like this:

main.go
package main

import "fmt"

func main() {
    var base float64 = 5
    var height float64 = 7
    var area float64 = 0.5 * base * height
    fmt.Println("The area of the triangle is:", area)
}
193 chars
11 lines

In this example, the base and height are set to 5 and 7 respectively, and the formula is used to calculate the area which is then printed to the console using fmt.Println(). You can modify the values of base and height to find the area of a triangle with different dimensions.

gistlibby LogSnag