Program for converting hours into minutes and seconds Last Updated : 13 Mar, 2023 Comments Improve Suggest changes Like Article Like Report Given an integer n which is the number of hours, the task is to convert it into minutes and seconds. Examples: Input: 5 Output: Minutes = 300, Seconds = 18000 Input: 2 Output: Minutes = 120, Seconds = 7200 Approach: h hours = h * 60 minutes as 1 hour = 60 minutes.Similarly h hours = h * 3600 seconds. Note: To convert m minutes back into hours, do n / 60 and for s seconds s / 3600.Below is the implementation of the above approach: C++ // C++ program to convert hours // into minutes and seconds #include <bits/stdc++.h> using namespace std; // Function to convert hours // into minutes and seconds void ConvertHours(int n) { long long int minutes, seconds; minutes = n * 60; seconds = n * 3600; cout << "Minutes = " << minutes << ", Seconds = " << seconds << endl; } // Driver code int main() { int n = 5; ConvertHours(n); return 0; } C // C program to convert hours // into minutes and seconds #include <stdio.h> // Function to convert hours // into minutes and seconds void ConvertHours(int n) { long long int minutes, seconds; minutes = n * 60; seconds = n * 3600; printf("Minutes = %lld, Seconds = %lld\n",minutes,seconds); } // Driver code int main() { int n = 5; ConvertHours(n); return 0; } // This code is contributed by kothavasaakash. Java // Java program to convert hours // into minutes and seconds import java.io.*; class GFG { // Function to convert hours // into minutes and seconds static void ConvertHours(int n) { int minutes, seconds; minutes = n * 60; seconds = n * 3600; System.out.println( "Minutes = " + minutes + ", Seconds = " + seconds); } // Driver code public static void main (String[] args) { int n = 5; ConvertHours(n); } } // This code is contributed by inder_verma.. C# // C# program to convert hours // into minutes and seconds using System; class GFG { // Function to convert hours into // minutes and seconds static void ConvertHours(int n) { int minutes, seconds; minutes = n * 60; seconds = n * 3600; Console.WriteLine("Minutes = " + minutes + ", Seconds = " + seconds); } // Driver code public static void Main () { int n = 5; ConvertHours(n); } } // This code is contributed by Ryuga PHP <?php // PHP program to convert hours // into minutes and seconds // Function to convert hours // into minutes and seconds function ConvertHours($n) { $minutes = $n * 60; $seconds = $n * 3600; echo "Minutes = " . $minutes . ", Seconds = " . $seconds . "\n"; } // Driver code $n = 5; ConvertHours($n); // This code is contributed // by Akanksha Rai ?> Python3 # C++ program to convert hours # into minutes and seconds # Function to convert hours # into minutes and seconds def ConvertHours(n): minutes = n * 60; seconds = n * 3600; print("Minutes = ", minutes \ ,", Seconds = " , seconds); # Driver code n = 5; ConvertHours(n); # This code contributed by Rajput-Ji JavaScript <script> // JavaScript program to convert hours // into minutes and seconds // Function to convert hours // into minutes and seconds function ConvertHours(n) { var minutes, seconds; minutes = n * 60; seconds = n * 3600; document.write("Minutes = " + minutes + ", Seconds = " + seconds); } // Driver code var n = 5; ConvertHours(n); // This code contributed by Rajput-Ji </script> Output: Minutes = 300, Seconds = 18000 Time Complexity : O(1)Auxiliary Space: O(1) Comment More infoAdvertise with us Next Article Program for converting hours into minutes and seconds G gfg_sal_gfg Follow Improve Article Tags : Technical Scripter C++ Programs Computer Science Fundamentals DSA Technical Scripter 2018 date-time-program +2 More Similar Reads C++ program to convert/normalize the given time into standard form Given three variables that represent the hours, minutes, and the second, the task is to write a C++ program to normalize/convert the given time into standard form i.e., HR: MIN: SEC format. Examples: Input: HR = 5, MIN = 125, SEC = 130Output: 7:7:10 Approach: To normalize the given time, below are t 3 min read Convert Unix timestamp to DD/MM/YYYY HH:MM:SS format Given a Unix Timestamp T (in seconds) for a given point in time, the task is to convert it to human-readable format (DD/MM/YYYY HH:MM:SS) Example: Input: T = 1595497956Output:23/7/2020 9:52:36Explanation:In unix time T have 1595497956 seconds, So it makes total 50 years, 7 months, 23 days and 9 hour 13 min read Convert time from 24 hour clock to 12 hour clock format Given a time in a 24-hour clock (military time), convert it to a 12-hour clock format. Note: Midnight is 00:00:00 on a 24-hour clock and 12:00:00 AM on a 12-hour clock. Noon is 12:00:00 on 24-hour clock and 12:00:00 PM on 12-hour clock. A string will be given of the format hh:mm: ss and output shoul 7 min read Digital Clock starting from user set time in C++ In this article, we will discuss the Digital Clock in C++ Language. It is an application that allows for a personal clock that starts at a custom set time and shows the time from that point onwards. This article describes how to make such a clock in a 24-hour format with HH:MM:SS slots and start the 3 min read Converting seconds into days, hours, minutes and seconds Given an integer n(in seconds).Convert it into days, hours, minutes and seconds.Examples: Input : 369121517Output : 4272 days 5 hours 45 minutes 17 secondsInput : 129600Output : 1 days 12 hours 0 minutes 0 seconds Number of days = ? n / (24 * 3600) ? Number of Hours = ? (n % (24 * 3600)) / 3600 ? Nu 4 min read Like