Techieindoor

Go – Program to calculate area of Rectangle and Square

Here, We are going to write a program to calculate area of Rectangle and Square in go golang. Area of rectangle is multiplication of length and breadth i.e length * breadth whereas area of Square is square of length i.e length * length.

Algorithm:

Example with code:

package main
 
import "fmt"
 
func main(){

  var length, breadth = 3, 4

  var area int

  area = length * breadth

  fmt.Println("Area of Rectangle : ", area)
    
  area = length * length

  fmt.Print("Area of Square : ", area)

}

Output:

Area of Rectangle :  12
Area of Square : 9

To learn more about golang, Please refer given below link.

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

References:

https://golang.org/doc/
https://golang.org/pkg/
Exit mobile version