C# program to convert hours to milliseconds

Views: 552   

Following program shows you how to convert hours to milliseconds.
In this program we get hours from user, once we get those we need to multiply with 60 so that we get in mintues, once we get mintues we need to multiply with 60 so that we get in seconds, once we get seconds we need to multiply with 1000 so that we get in milliseconds

using System;

class MainClass {
  public static void Main (string[] args) {
    Console.WriteLine ("Please enter hours:");
    int hours = Convert.ToInt32(Console.ReadLine());
    int milliseconds = hours * 60 * 60 *1000;
    Console.WriteLine(milliseconds + " Milliseconds");
  }
}

Output:

Please enter hours:
 5
18000000 Milliseconds
On By