Menu Close

Go – Program to find area of semi circle in go

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

Algorithm:

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

Area of a Circle Formula:

area_of_a_circle = (pi * radius * radius) / 2

Input : 
a = 3

Output : 
14.137167

Input : 
a = 5

Output :
39.26991

Code:

package main

import (

  "fmt"
  "math"

)

func area_of_circle(radius int) float32  {

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

  return res

}

func main() {


  area := area_of_circle(3)

  fmt.Println(area)


  area = area_of_circle(5)

  fmt.Println(area)

}

Output:

14.137167

39.26991

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. Required fields are marked *