Program to find the time remaining for the day to complete - GeeksforGeeks

11 May, 2021
Given the current time in the form of HH::MM, where H represents the hours and M, represents the minutes in a 24-hour time format. The task is to calculate the time remaining for the day to complete as HH::MM.Examples:  
Input: HH::MM = 00::01
Output: 23::01

Input: HH::MM = 23::55
Output: 00::05
 
Approach:  
Since the total minutes in a 24 hour complete day is 24 * 60 = 1440 minutesCalculate the time completed in minutesCalculate the time remaining in the form of minutes as total minutes – time completedConvert the time remaining in the form of HH::MM
Since the total minutes in a 24 hour complete day is 24 * 60 = 1440 minutes
Calculate the time completed in minutes
Calculate the time remaining in the form of minutes as total minutes – time completed
Convert the time remaining in the form of HH::MM
Below is the implementation of the above approach:  
CPP
Java
Python
C#
Javascript
#include <bits/stdc++.h>using namespace std; // Function to find the remaining timevoid remainingTime(int h, int m){    int totalMin, hoursRemaining, minRemaining;     // Formula for total remaining minutes    // = 1440 - 60h - m    totalMin = 1440 - 60 * h - m;     // Remaining hours    hoursRemaining = totalMin / 60;     // Remaining minutes    minRemaining = totalMin % 60;     cout << hoursRemaining << "::"         << minRemaining << endl;} // Driver codeint main(){     // Current time    int h = 0, m = 1;     // Get the remaining time    remainingTime(h, m);     return 0;}
class GFG{ // Function to find the remaining timestatic void remainingTime(int h, int m){    int totalMin, hoursRemaining, minRemaining;     // Formula for total remaining minutes    // = 1440 - 60h - m    totalMin = 1440 - 60 * h - m;     // Remaining hours    hoursRemaining = totalMin / 60;     // Remaining minutes    minRemaining = totalMin % 60;     System.out.print(hoursRemaining+ "::"        + minRemaining +"\n");} // Driver codepublic static void main(String[] args){     // Current time    int h = 0, m = 1;     // Get the remaining time    remainingTime(h, m);}} // This code is contributed by Rajput-Ji
# Function to find the remaining timedef remainingTime(h, m):     # Formula for total remaining minutes    # = 1440 - 60h - m    totalMin = 1440 - 60 * h - m     # Remaining hours    hoursRemaining = totalMin // 60     # Remaining minutes    minRemaining = totalMin % 60     print(hoursRemaining,"::",minRemaining) # Driver code # Current timeh = 0m = 1 # Get the remaining timeremainingTime(h, m) # This code is contributed by mohit kumar 29
// C# program to Number of pairs of lines// having integer intersection pointsusing System; class GFG{     // Function to find the remaining time    static void remainingTime(int h, int m)    {        int totalMin, hoursRemaining, minRemaining;             // Formula for total remaining minutes        // = 1440 - 60h - m        totalMin = 1440 - 60 * h - m;             // Remaining hours        hoursRemaining = totalMin / 60;             // Remaining minutes        minRemaining = totalMin % 60;             Console.WriteLine(hoursRemaining+ "::"                            + minRemaining);    }         // Driver code    public static void Main()    {             // Current time        int h = 0, m = 1;             // Get the remaining time        remainingTime(h, m);    }} // This code is contributed by AnkitRai01
<script> // Javascript program to Number of pairs of lines// having integer intersection points        // Function to find the remaining time    function remainingTime(h, m)    {        var totalMin, hoursRemaining, minRemaining;               // Formula for total remaining minutes        // = 1440 - 60h - m                 totalMin = 1440 - 60 * h - m;               // Remaining hours                 hoursRemaining = totalMin / 60;               // Remaining minutes                 minRemaining = totalMin % 60;               document.write(Math.trunc(hoursRemaining)+        "::" + minRemaining);    }           // Driver code                // Current time        var h = 0, m = 1;               // Get the remaining time        remainingTime(h, m);         </script>
23::59
 
mohit kumar 29
Rajput-Ji
ankthon
bunnyram19
Mathematical
School Programming
Mathematical
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Program to print prime numbers from 1 to N.
Segment Tree | Set 1 (Sum of given range)
Modular multiplicative inverse
Count all possible paths from top left to bottom right of a mXn matrix
Fizz Buzz Implementation
Python Dictionary
Arrays in C/C++
Inheritance in C++
Reverse a string in Java
C++ Classes and Objects