Go language program to calculate triangle circumference

Views: 130   

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)


Enter the side1 of triangle:
Enter the side2 of triangle:
Enter the side3 of triangle:
Circumference of triangle is:  45
On By