Go Program To Find Area Of Square (Golang) - This Go program to calculate an area of a square, The program takes the length of the square as input, calculates the area of the square and outputs it on the screen.
Source Code :
package main
import "fmt"
func main() {
var length, area int
fmt.Print("Enter length of square: ")
fmt.Scanln(&length)
area = length * length
fmt.Println("Area of square is: ", area)
}
Compile & Run :
Here's how to compile source code manually:
$ go build areaofsquare.go
$ ./areaofsquare
Run without compile:
$ go run areaofsquare.go
Output Of Program :
The result of Golang program to find area of square |