// header files #include #include #include #include // local constants #define SECONDS_IN_DAY 86400 #define SECONDS_IN_HOUR 3600 #define SECONDS_IN_MINUTE 60 #define TIME_CONSTANT_SECONDS 8675309 /* Name: Day/Hour/Minute/Second Calculator Process: Given a number of seconds, figure out how many days, hours, minutes and seconds fits. Function input/parameters: NONE Function output/parameters: NONE Function output/returned: NONE Device input/---: NONE Device output/---: NONE Dependencies: included by standard libraries */ int main() { // define local variables int totalDays, totalHours, totalMinutes, totalSeconds; // do calculations // need to modulo then divide by last time unit for each part. totalSeconds = TIME_CONSTANT_SECONDS % SECONDS_IN_MINUTE; totalMinutes = (TIME_CONSTANT_SECONDS % SECONDS_IN_HOUR) / SECONDS_IN_MINUTE; totalHours = (TIME_CONSTANT_SECONDS % SECONDS_IN_DAY) / SECONDS_IN_HOUR; totalDays = (TIME_CONSTANT_SECONDS % (SECONDS_IN_DAY * 30)) / SECONDS_IN_DAY; // display results printf("In %d seconds, there are: %d days, %d hours, %d minutes, %d seconds\n", TIME_CONSTANT_SECONDS, totalDays, totalHours, totalMinutes, totalSeconds); // return success return 0; }