FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 75   



Following program shows you how to calculate triangle area.
This program gets triangle base and height from user and calculates area and prints it using following formula
Area = base X height / 2

package main

import "fmt"

func main() {

  var triangleBase float64
  var triangleHeight float64
  var areaOfTriangle float64
  fmt.Println("Enter the base of triangle:")
  fmt.Scanf("%f", &triangleBase)
  fmt.Println("Enter the height of triangle:")
  fmt.Scanf("%f", &triangleHeight)
  areaOfTriangle = (triangleBase * triangleHeight) / 2
  fmt.Println("Area of triangle is: " , areaOfTriangle)
  }

Output:

Enter the base of triangle:
 12
Enter the height of triangle:
 15
Area of triangle is:  90



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News