# Program to find the time remaining for the day to complete

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::01Output:23::01Input:HH::MM = 23::55Output:00::05

**Approach:**

- 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 remanining in the form of HH::MM

Below is the implementation of the above approach:

## CPP

`#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// Function to find the remaining time ` `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; ` ` ` ` ` `cout << hoursRemaining << ` `"::"` ` ` `<< minRemaining << endl; ` `} ` ` ` `// Driver code ` `int` `main() ` `{ ` ` ` ` ` `// Current time ` ` ` `int` `h = 0, m = 1; ` ` ` ` ` `// Get the remaining time ` ` ` `remainingTime(h, m); ` ` ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`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` `; ` ` ` ` ` `System.out.print(hoursRemaining+ ` `"::"` ` ` `+ minRemaining +` `"\n"` `); ` `} ` ` ` `// Driver code ` `public` `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 ` |

*chevron_right*

*filter_none*

## Python

`# Function to find the remaining time ` `def` `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 time ` `h ` `=` `0` `m ` `=` `1` ` ` `# Get the remaining time ` `remainingTime(h, m) ` ` ` `# This code is contributed by mohit kumar 29 ` |

*chevron_right*

*filter_none*

## C#

`// C# program to Number of pairs of lines ` `// having integer intersection points ` `using` `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 ` |

*chevron_right*

*filter_none*

**Output:**

23::59

GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details

## Recommended Posts:

- Program to find total number of edges in a Complete Graph
- Program to find the time after K minutes from given time
- Minimum time required to complete a work by N persons together
- Find the remaining balance after the transaction
- Program to check if tank will overflow, underflow or filled in given time
- Find the number of spectators standing in the stadium at time t
- Find Index of given fibonacci number in constant time
- Find the largest multiple of 3 from array of digits | Set 2 (In O(n) time and O(1) space)
- Find a time for which angle between hour and minute hands is given theta
- Time difference between expected time and given time
- Area of plot remaining at the end
- Element equal to the sum of all the remaining elements
- Check if the array has an element which is equal to sum of all the remaining elements
- Count the subarray with sum strictly greater than the sum of remaining elements
- Python program to convert time from 12 hour to 24 hour format

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.