So im trying to figure out how to make a program that converts seconds to hours, minutes, and seconds....but I cant seem to get how when i run the program.. the program will say enter the seconds and the output will be the seconds are equal to hours minutes and seconds. help...its bugging me that i cant figure it out. what should i add to this code :
Code:
#include <stdio.h>
#define NROFITEMS 3
int values[NROFITEMS] = {3600, 60, 1};
int count[NROFITEMS];
char *names[NROFITEMS] = {"hours", "minutes", "seconds"};
int main (int argc, const char * argv[])
{
int i, total = 6789;
for (i = 0; i < NROFITEMS; ++i) {
count[i] = total / values[i];
total -= count[i] * values[i];
}
for (i = 0; i < NROFITEMS; ++i) {
printf("\n%s: %i", names[i], count[i]);
}
return 0;
}