Command Line: none
Prompt: "Please enter the number of seconds: "
Input: a base-10 integer
Output: "nn seconds = xx days, yy hours, zz minutes and ss seconds."
where:
"nn" is the total number of seconds that the user had input;
"xx" is the number of days that fit into nn seconds;
"yy" is the number of hours left over after subtracting xx days from the input;
"zz" is the number of minutes left over after subtracting xx days and yy hours from the input;
"ss" is the number of seconds left over after subtracting xx days, yy hours and zz minutes from the input.
Example: (user input is written in bold)
%> ./lab1 Please enter the number of seconds: 677732 677732 seconds = 7 days, 20 hours, 15 minutes and 32 seconds. %>You do not have to worry about zero-padding your numbers; that is, you can say "7 seconds" rather than "07 seconds".
#includeint main() { return 0; }
Save this template on your M: drive (or another network drive, if you prefer, but stay away from a USB drive or the C: drive) as "lab1.c".
Now, everything else will go after the "{" and before the "return 0;".
In particular, you first need to decide what variables you will need. You will probably want at least the following:
input_seconds, days, hours, minutes, seconds, remainder
The first one is to hold the value of seconds the user types in; the next four will be calculated by you; the last one is a temporary variable to help with the calculations.
All variables are of type "int". At the start of the main() function, you must declare all this variables so the compiler knows you want to use them, and can assign space in RAM for each one:
int input_seconds; int day, hour, minutes ... etc.
For now, don't worry about getting input from the user; just assign a value to "input_seconds" so you can work out the solution first and worry about input and output later.
input_seconds = 677732
Now go ahead and compute days, hours, minutes and seconds. Read up on printf() so you can display the computed values. Once you get that correct, read up on scanf() so you can get the input_seconds from the user, rather than hard-coding the value. Finally, go over your input and output so they match exactly what is described above.