Go language program to calculate circle area

Views: 148   

Following program shows you how to calculate circle area.
In this tutorial will get circle radius from user and calculate area and prints it using following formula
Area = PI X r X r

package main

import "fmt"

func main() {

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


Please enter the radius of circle:
Area of circle is:  108
On By