FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 112   



Following program shows you how to calculate square area and circumference.
This program gets square length from user and calculates area and circumference and prints them using following formulas
Area = length X length
Circumference = 4 X length

package main

import "fmt"

func main() {

  var squareLength float64
  var areaOfSquare float64
  var circumferenceOfSquare float64
  fmt.Println("Enter length of square:")
  fmt.Scanf("%f", &squareLength)
  areaOfSquare = squareLength * squareLength
  fmt.Println("Area of square is: " , areaOfSquare)
  circumferenceOfSquare = 4 * squareLength
  fmt.Println("Circumference of square is: " , circumferenceOfSquare)
}

Output:

Enter length of square:
 8
Area of square is:  64
Circumference of square is:  32



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News