
A nice, simple question
I have been keeping a log file for how many seconds I have been testing out my latest program, using the clock() function. Now, I want to convert this into days, hours, minutes, and seconds. I know modulus division is involved somewhere, but I never did pay attention to that ;) ...

Here's how
Code:
int a = 7;
int b = 3;
cout << a%b << endl;
(or)
printf("%d", a%b);
OUTPUT:
1
"%" is the modulus "/"
COOL PROGRAMS @ www.akilla.tk

Yes...well...
I know how to do modulus division, it just leaves a remainder, but I was wondering how I convert seconds into various other time increments? Do I first put the seconds into days, then do modulus division by 24 to get hours????????????????????? Kill me now ;)

An hour has 3600 secs so if you divide the number of secs you have with 3600 you'll get the hour
Code:
int totsec=36250; //assuming this value
int hrs,min,rem; //rem=remainder time
hrs=totsec/3600;
rem=totsec%3600;
min=rem/60;
rem=rem%60;
cout<<"30,000 seconds = "<<hrs<<" HOURS, "<<min<<" MINUTES and "<<rem<<" SECONDS";
the ouptut should be : 10 HOURS, 4 MINUTES and 10 SECONDS
i hope this is what you are asking.. :D

Ah, ihsir, thank you for the help, that is exactly what I am asking :)