Go language program to convert kilograms to grams

Views: 111   

Following program shows you how to convert kilograms to grams.
In this program we get kilograms from user, once we get those we need to multiply with 1000 so that we get in grams

package main

import "fmt"

func main() {

  var kilograms float64
  var grams float64
  fmt.Println("Please enter kilograms:")
  fmt.Scanf("%f", &kilograms)
  grams = kilograms * 1000
  fmt.Println(grams , " Grams")
}

Output:

Please enter kilograms:
 8
8000  Grams
On By