Menu Close

Go – Program to find area of circle in go

Here, we will see program to find area of circle in go. Given below, you can find algorithm and program.

Algorithm:

  • You are given radius of circle.
  • Calculate the area of circle using standard formula
  • Return this result

Area of a Circle Formula:

area_of_a_circle = pi * radius * radius

Input : 
a = 3

Output : 
28.274334

Input : 
a = 5

Output :
78.53982

Code:

package main

import (

  "fmt"
  "math"

)

func area_of_circle(radius int) float32  {

  res := math.Pi * float32(radius) * float32(radius)

  return res

}

func main() {


  area := area_of_circle(3)

  fmt.Println(area)


  area = area_of_circle(5)

  fmt.Println(area)

}

Output:

28.274334

78.53982

To learn more about golang. Please follow given below link.

https://www.techieindoor.com/go-lang/

References:

https://golang.org/doc/
https://golang.org/pkg/
Posted in golang, golang program

Leave a Reply

Your email address will not be published.

Contact Us