Go language program to take a number as input and calculate the square of that number


Following program shows how to take a number as input and calculate the square of that number.
In this program we get input from user and prints square of that number using following formula
Square of number = input X input

package main

import "fmt"

func main() {

  var input int
  var result int
  fmt.Println("Please enter a number:")
  fmt.Scanf("%d", &input)
  result = input * input
  fmt.Println("Squre of " , input , " is: " ,result)
}

Output:

Please enter a number:
 12
Squre of  12  is:  144