Learning by doing: Reading books and trying to understand the (code) examples
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
449 B

  1. #include <stdio.h>
  2. #define MIN_PER_HOUR 60
  3. unsigned getMinutes(void);
  4. int main (void) {
  5. unsigned min;
  6. min = getMinutes();
  7. while (min != 0) {
  8. printf("%u minutes are %u:%02u HH:MM\n", min, min/MIN_PER_HOUR, min % MIN_PER_HOUR);
  9. min = getMinutes();
  10. }
  11. return 0;
  12. }
  13. unsigned getMinutes(void) {
  14. unsigned min;
  15. printf("Time in minutes (0 to quit): ");
  16. if (scanf("%u", &min) != 1) {
  17. min = 0;
  18. }
  19. return min;
  20. }