This is the language C and as the title says I am trying to make it so that the users put in seconds and that gets converted to weeks, days, hours, minutes and seconds like this:
Input: x seconds
Output: Weeks x, days x, hours 59, minutes 59, seconds 59 - Just an example.
Code:
int main(void) {
int w, d, h, m, s;
printf("Please enter amount of seconds: " );
//%d er placeholder og &s er den enhed som benyttes - i dette tilfælde sekunder.
scanf("%d",&s);
//1 week = 7 days.
w = d / 7;
d = d % 7;
//1 day = 24 hours.
d = h / 24;
h = h % 24;
//1 hour = 60 minutes.
h = m / 60;
m = m % 60;
//1 minute = 60 seconds.
m = s / 60;
s = s % 60;
printf("\nWeeks: %d", h);
printf("\nDays: %d", h);
printf("\nHours: %d", h);
printf("\nMinutes: %d", h);
printf("\nSeconds: %d", h);
return 0;
}
My question: When I try compiling this, it just prints out 70019 in all the fields regarding of input - I suppose this is the last memory used? So obviously something is wrong, but I ain't good enough to figure it out :/