Explore BrainMass
Share

C program for Time conversion

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

Construct a library Time that contains the time-conversion functions (given a number of seconds, returns the equivalent number of minutes; given the number of minutes, returns the equivalent number of hours; given the number of hours, returns the equivalent number of days; given the number of seconds, returns the equivalent number of days). Write a driver program to test your library.

© BrainMass Inc. brainmass.com October 24, 2018, 6:06 pm ad1c9bdddf
https://brainmass.com/computer-science/c/c-program-for-time-conversion-31576

Solution Preview

First compile the library file
gcc -c myTime.c
this will create myTime.o

then simply do
gcc -o test testTime.c myTime.o
remember that the header file myTime.h containing the signatures of the functions should be included in your test driver file

Here is the code file
myTime.c
/* To compile the functions into a library ...

Solution Summary

Three source code files will show you how to write appropriate functions to convert different time scales/metrics. This can be useful in
a) code to write software clock or watch
b) understanding of how to use multiple files for a single project
c) understanding of the use of header files

This will show how to compile multiple files into one executable file.

$2.19
See Also This Related BrainMass Solution

Calculation and conversion of time given in hours, minutes and seconds

1- inputs a time duration in hours, minutes, and seconds;
2-calculates the equivalent total number of seconds;
3-recalculates the hours, minutes, and seconds from the total;
4-displays the values of the hours, minutes, seconds, and total seconds.

Specific Requirements

1-The program must be otherwise formatted and documented
2-The program should contain a single method, main
3-The program should declare 4 variables, hours, minutes, seconds, and totalSeconds, all of type int. You may declare at most 1 additional variable for temporary usage. No other variable are allowed.
4- The program should declare and use exactly 2 constants, MIN_PER_HR and SEC_PER_MIN (minutes per hour and seconds per minute)
5-The input statement(s) must be preceded by a suitable prompt(s).
6-The output produced by your program should be a single line

View Full Posting Details