logo image

Go language program to convert grams to kilograms

Views: 20

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

package main

import "fmt"

func main() {

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


Please enter grams:
0.25  Kilograms