+ 1
How can i make an input numbers convert into hours, minutes and seconds?
for example: if i type : 124540 it should display hours = 34 minutes = 35 secinds = 40 thanks in advance
5 Réponses
+ 2
by using div. / and mod. %
+ 1
Sami has the right answer, but here is how you think about this logically. Your input is in seconds. You need to find out how many hours that is by dividing by 3600 (or 60*60):
hr = input / 3600;
Now you have hours. The remainder of that division will be your minutes and seconds, so take the remainder of dividing by 3600:
rem = input % 3600;
And divide that by 60 to get minutes:
min = rem / 60;
The remainder of this is seconds:
sec = rem % 60;
I hope this helps
0
yes