1. ## hour,minutes & seconds

Hi. Whats wrong here?
Code:
```hour = total_sec /3600;
min = total_sec % 60;
sec = min % 60;```

2. Your calculation of min doesn't really bear any resemblance to what a minute is.

3. Say you're given an integer 123, and your task is to extract each digit using /10 and %10

Well it's exactly the same, except hms uses /60 and %60

4. explain please? I thought 3600/60= 60.

5. It is. Is that relevant? No. (EDIT: A hint, because I'm feeling generous. 120 seconds is 2 minutes. What is 120%60?)

6. Yes.true & it was working for me when I was just doing minutes & seconds, but when I included hours it didn't.like so
Code:
```#include <stdio.h>

int main()
{
int input_v,hour,min,sec;

printf("input number in total seconds\n");
scanf("%d", &input_v);
while(input_v > 3600){
hour = input_v /3600;
min = input_v % 60;
sec = min % 60;
printf("%dhours%dminutes and %dseconds\n",hour,min,sec);
}
min = input_v / 60;
sec = input_v % 60;
printf("%dminutes and %dseconds\n",min,sec);
return 0;
}```

7. That's because you did something completely different (and, coincidentally, correct). Compare your correct version on line 15 with your not-at-all correct version on line 11.

8. cheers tabstop

9. So this works with the while statement commented out. Whats wrong with the while?
Code:
```#include <stdio.h>
int main()
{
int input_v,hour,min,sec;

printf("input total seconds\n");
scanf("%d", &input_v);
hour=input_v/3600;
min=(input_v%3600)/60;
sec=(input_v%60)%60;
/*while(hour<2){
printf"%dhour %dminutes %dseconds\n",hour,min,sec);
}*/
printf("%dhours %dminutes %dseconds\n",hour,min,sec);

return 0;
}```

10. How is hour going to change inside the loop? If you get in, you can never get out. You probably meant "if" instead.

11. Hey guys. I'm new here and new on C.

Im also trying to convert seconds to hours, minutes, seconds.

I got this but i cant seem to make it work. I can compile it but it exits there's really something wrong. Can anyone point out the problem or can give a hint.

Code:
```#include <stdio.h>

main( )

{
int input, hr, min, sec;

printf("Input Value: ");
scanf ("%d", &input);
hr = (input/3600);
min =(input%3600)/60;
sec = (input%60)%60;
printf ("%d Hours, %d Minutes, %d seconds", hr, min, sec);
}```

12. Once a program is finished, it always exits; that's just the way programs work. So once it prints the Hours, Minutes, and Seconds, there's nothing left for it to do, so it stops. You should be running this program from the console anyway so that you can see the output.

(Also: This thread wasn't extremely dead, but in general you make a new thread and maybe make a link to the old one if you need to refer to it. In this case you don't refer to anything that comes before, so putting it in an old thread isn't useful.)

13. Couple of preliminary things:

1) If you have a new question, you might as well start a new thread. If you think it relates substantially to some other thread, add a link.

2) the return type of main is int, and it should do so:

Code:
```int main (void) {
return 0;
}```

Beyond that, your code is fine, I ran it, it compiles without errors (but there is a warning about the return type of main) and it works. I suspect you are working on MS Windows, and by "exit" you mean the window disappears. Add something like this at the end:

Code:
```	int c = 0;
while (c != 'q') c = getchar();```
Now you have to enter q (and return) to end the program.

14. Read the forum guidelines. You shouldn't be posting to a thread more than two weeks old. Make your own next time.

It's int main(void), and return an int at the end, usually 0 for success.

Lastly, your code works, apart from the int main thing. There's not really something wrong, you just need to keep the console window open until you're done. Read this: Cprogramming.com FAQ > Stop my Windows Console from disappearing everytime I run my program?

15. Thank you tabstop, MK27 and anduril462.

I'm so stupid. I didn't know about that console disappearing. Thank you for the inputs it was an enlightenment

I'm sorry about bumping the topic. I'll be reading the guidelines before posting again.