47 lines
No EOL
1.5 KiB
C
47 lines
No EOL
1.5 KiB
C
// header files
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <math.h>
|
|
|
|
// local constants
|
|
#define SECONDS_IN_YEAR 31449600
|
|
#define SECONDS_IN_WEEK 604800
|
|
#define SECONDS_IN_DAY 86400
|
|
#define SECONDS_IN_HOUR 3600
|
|
#define SECONDS_IN_MINUTE 60
|
|
|
|
#define TIME_CONSTANT_YEARS 3
|
|
#define TIME_CONSTANT_WEEKS 6
|
|
#define TIME_CONSTANT_DAYS 5
|
|
#define TIME_CONSTANT_HOURS 2
|
|
#define TIME_CONSTANT_MINUTES 5
|
|
|
|
/*
|
|
Name: Seconds in TIME_CONSTANT
|
|
Process: Calculates the amount of time in seconds that an amount of
|
|
years/weeks/days/hours/minutes in total seconds.
|
|
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 totalTime;
|
|
// do calculations
|
|
totalTime = (TIME_CONSTANT_YEARS * SECONDS_IN_YEAR) +
|
|
(TIME_CONSTANT_WEEKS * SECONDS_IN_WEEK) +
|
|
(TIME_CONSTANT_DAYS * SECONDS_IN_DAY) +
|
|
(TIME_CONSTANT_HOURS * SECONDS_IN_HOUR) +
|
|
(TIME_CONSTANT_MINUTES * SECONDS_IN_MINUTE);
|
|
// display results
|
|
printf("The total number of seconds in %d years, %d weeks, %d days, %d hours, and %d minutes is: %d seconds\n",
|
|
TIME_CONSTANT_YEARS, TIME_CONSTANT_WEEKS, TIME_CONSTANT_DAYS,
|
|
TIME_CONSTANT_HOURS, TIME_CONSTANT_MINUTES, totalTime);
|
|
// return success
|
|
return 0;
|
|
} |