C# program to convert hours to seconds

Views: 156   

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

using System;

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

Output:

Please enter hours:
 12
43200 Seconds
On By