Code:
/* Don't name the executable "time.exe", as this is a conflicting
name in some environments
*/
#include <stdio.h>
#define HOURSEC 3600
#define MINSEC 60
void my_time(const unsigned, unsigned*, unsigned*, unsigned*);
int main()
{
unsigned time_in_secs, hours, mins, secs;
printf("Enter a time in seconds: ");
scanf("%d", &time_in_secs);
my_time(time_in_secs, &hours, &mins, &secs);
printf(" hours = %d\nminutes = %d\nseconds = %d\n", hours, mins, secs);
return 0;
}
void my_time (const unsigned t, unsigned *h, unsigned *m, unsigned *s)
{
*h = t / HOURSEC;
*m = (t - HOURSEC * *h) / MINSEC;
*s = t % MINSEC;
}