Go language program to convert kilometers to miles

Views: 13   

Following program shows you how to convert kilometers to miles.
In this program we get kilometers from user, once we get those we need to divide with 1.6 so that we get in miles

package main

import "fmt"

func main() {

  var kilometers float64
  var miles float64
  fmt.Println("Please enter kilometers:")
  fmt.Scanf("%f", &kilometers)
  miles = kilometers / 1.6
  fmt.Println(miles , " Miles")
}

Output:

Please enter kilometers:
 12
7.5  Miles
On By