logo image

Go language program to calculate circle area

33


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)
}

Output:

Please enter the radius of circle:
 6
Area of circle is:  108