FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 22   



Following program shows you how to calculate triangle circumference.
This program gets triangle sides from user and calculates circumference and prints it using following formula
Circumference = side1 + side2 + side3

package main

import "fmt"

func main() {

  var triangleSide1 float64
  var triangleSide2 float64
  var triangleSide3 float64
  var circumferenceOfTriangle float64
  fmt.Println("Enter the side1 of triangle:")
  fmt.Scanf("%f", &triangleSide1)
  fmt.Println("Enter the side2 of triangle:")
  fmt.Scanf("%f", &triangleSide2)
  fmt.Println("Enter the side3 of triangle:")
  fmt.Scanf("%f", &triangleSide3)
  circumferenceOfTriangle = triangleSide1 + triangleSide2 + triangleSide3
  fmt.Println("Circumference of triangle is: " , circumferenceOfTriangle)
  }

Output:

Enter the side1 of triangle:
 12
Enter the side2 of triangle:
 18
Enter the side3 of triangle:
 15
Circumference of triangle is:  45



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News