C# program to convert grams to kilograms

3072


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

using System;

class MainClass {
  public static void Main (string[] args) {
    Console.WriteLine ("Please enter grams:");
    double grams = Convert.ToDouble(Console.ReadLine());
    double kilograms = grams / 1000;
    Console.WriteLine(kilograms + " Kilograms");
  }
}

Output:

Please enter grams:
 5000
5 Kilograms