Hi, so I am making a program that hinges on a function that takes a total amount of seconds as input and is supposed to output using printf the number of days, hours, minutes, and seconds. The program is now able to compile, but I am not getting the output that I expected. Any advice?
Thanks.Code:#include <stdio.h> #include <math.h> #include "checkit.h" /* function declarations */ /* time conversion function */ void convertTime(int seconds); #define Sec_per_day 86400 #define Sec_per_hr 3600 #define Sec_per_min 60 /* function definitions */ void convertTime(int seconds){ int Days; int Hrs; int Mins; int Secs; Days = seconds/Sec_per_day; /* int division returns # of days */ Hrs = (seconds%Sec_per_day)/Sec_per_hr; /* left over seconds returns hrs */ Mins = ((seconds%Sec_per_day)%Sec_per_hr)/Sec_per_min; /* left over seconds returns mins */ Secs = ((seconds%Sec_per_day)%Sec_per_hr)%Sec_per_min; /* left over seconds */ printf("Elapsed time: %d days, %d hours, %d minutes, %d seconds\n", Days, Hrs, Mins, Secs); }



LinkBack URL
About LinkBacks



