Go language program to calculate circle circumference

Views: 94   

Following program shows you how to calculate circle circumference.
In this program we get circle radius from user and calculate circumference using following formula
Circumference = 2 X PI X r

package main

import "fmt"

func main() {

  var circleRadius float64
  var circumferenceOfCircle float64
  fmt.Println("Please enter the radius of circle:")
  fmt.Scanf("%f", &circleRadius)
  circumferenceOfCircle = 2 * 22/7 * circleRadius
  fmt.Println("Circumference of circle is: " , circumferenceOfCircle)
}

Output:

Please enter the radius of circle:
 9
Circumference of circle is:  54
On By