Previous Next
0 / 6
Module DEMO-32-57DEMO-C-32

Time Addition

DEMO-C-32 • Programming in C

Browser-only practice

Problem Statement

Time Addition (24-hour format, Next Day)

You are given a time in 24-hour format (HH MM) and a duration in minutes (k). Your task is to compute the resulting time after adding the duration to the initial time.

If the resulting time is past midnight (i.e., it falls on the next day), append Next day to the output.

Examples

  • Adding 25 minutes to 23:50 results in 00:15 Next day
  • Adding 30 minutes to 10:05 results in 10:35

Notes

  • Use proper formatting with leading zeros for hours and minutes (e.g., 05:07)
  • You may find the modulo operator (%) helpful for handling time wraparound

Constraints

0 ≤ HH ≤ 23 0 ≤ MM ≤ 59 0 ≤ k ≤ 2000

Input Format

Input consists of:

  • A line containing two integers HH and MM, representing the starting time in 24-hour format.
  • A second line containing a single integer k, the number of minutes to add.

Output Format

Output the resulting time in HH:MM format.

If the result is past midnight (i.e., the next day), append Next day to the output line.

Example outputs:

  • 10:35
  • 00:15 Next day

Sample Testcases

Submit runs every public testcase in this browser. Results and code never leave this device.

Sample #1
Public sample
23 50
25
00:15 Next day
Adding 25 minutes to 23:50 results in 00:15 the next day.
Sample #2
Public sample
22 45
75
00:00 Next day
Adding 75 minutes to 22:45 results in exactly midnight the next day.
Sample #3
Public sample
10 05
30
10:35
Adding 30 minutes to 10:05 results in 10:35 on the same day.

Web terminal

C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.

Saved in this browser
Editor settings