
Patrick B. answered 07/09/21
Math and computer tutor/teacher
1st: it's not Java if you use printf. It's C ; I have already told you this once before
2nd: You have to understand the math. The remainder operator % gives you the remainder of the division, not the quotient. For example, 10 %3 = 1 because 1 is the remainder when 10 is divided by 3.
3rd: walks though the example so you understand the math...
5000 seconds is the input...
1 minute = 60 seconds; 1 hour = 60 minutes;
5000/60 = 83 with remainder 20 --> 83 min 20 sec
83 minutes = 83/60 hours = 1 hour 23 minutes
so final answer is 1 hour 23 minutes 20 seconds
#include <stdio.h>
int main()
{
long lSeconds;
printf(" input # of seconds :>");
scanf("%ld",&lSeconds);
long lSec = lSeconds%60;
long lMinutes = lSeconds/60;
long lMin = lMinutes % 60;
long lHours = lMinutes/60;
printf(" %ld hr %ld min %ld sec \n",lHours,lMin,lSec);
return 0;
}