PDA

View Full Version : C. modulus operator



jon zendatta
May 28th, 2011, 01:42 AM
How do I express seconds as hour,minutes,seconds?
This worked

min = total_seconds / 60;
sec = total_seconds % 60;
This did not.

hour = total_seconds / 3600;
min = total_seconds % 3600;
sec = min % 60;

NovaAesa
May 28th, 2011, 02:18 AM
Try something like this:


hour = total_sec / 3600;
min = (total_sec % 3600) / 60;
sec = (total_sec % 3600) % 60;

jon zendatta
May 28th, 2011, 02:28 AM
Thanks NovaAesa