I'm trying to convert seconds to hours. I'd like to be able to convert 3600 to read 1.0 and 5400 (1 and 1/2 hours) to 1.5 and so on..
If anybody could shed some light on this simple problem I'd greatly appreciate it!
Thank you.
I'm trying to convert seconds to hours. I'd like to be able to convert 3600 to read 1.0 and 5400 (1 and 1/2 hours) to 1.5 and so on..
If anybody could shed some light on this simple problem I'd greatly appreciate it!
Thank you.
You'll kick yourself when you see this one.
All you have to do is divide by 3600.Code:time_val = 5400; time_dec = time_val / 3600;
Yeah. I guess you were right.
This i what I did.
Code:#include <stdio.h> #define SECSPERHOUR 3600 int main(void) { float secs=7100; secs = secs / SECSPERHOUR; printf("Hours: %.02f\n", secs); }
Hmmmmmmmmm
Where is the return statement in the code ?
Don't you think it's not a cool habit of writing code.Just return some integer to main(). Why you have forced main() to stay without food ?
REAL NAPSTER