QA.TechInterviews.com - your tech questions answered
Write A C++ Program To Convert Seconds To Hours, Minutes And Sconds?

Once again, this appears to be some sort of exercise problem. In any case, another nudge in the right direction.

You know the number of seconds. Start by finding how many minutes there are. You can use modulus. Then find out how many seconds are left over using some simple arithmetic. That's the number of seconds. Then, use the number of minutes to do the same thing and find the number of hours (again using %).
Once again, this appears to be some sort of exercise problem. In any case, another nudge in the right direction.

You know the number of seconds. Start by finding how many minutes there are. You can use modulus. Then find out how many seconds are left over using some simple arithmetic. That's the number of seconds. Then, use the number of minutes to do the same thing and find the number of hours (again using %).
try to solve ur self hint
1 min = 60 seconds
1 hrs = 60 mins


:)
now try
// start value
int secs;
// result
int hours, minutes, seconds;

hours = secs / 3600;
secs -= hours * 3600;
minutes = secs / 60;
seconds = secs - minutes * 60;

Back to QA. TechInterviews.com. Powered by Yahoo! Answers and TechInterviews.com community.