Seconds to Time
Completed
Read a number of seconds and print it as HH:MM:SS, each part with two digits.
Input
One integer 0–86399.
Output
One line.
Example
Input
3725
Output
01:02:05
Editor
C
Hints
%02d pads with a leading zero to 2 digits.
Solution explanation
/ and % split a number into units.
Show solution
#include <stdio.h>
int main() {
int t;
scanf("%d", &t);
printf("%02d:%02d:%02d\n", t / 3600, t % 3600 / 60, t % 60);
return 0;
}