44 lines
No EOL
1.1 KiB
C
44 lines
No EOL
1.1 KiB
C
// header files
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <math.h>
|
|
|
|
// local constants
|
|
|
|
/*
|
|
Name: Temperature Chart
|
|
Process: Accepts up to three numbers and prints out the Fahrenheit and Celcius
|
|
degrees between the two numbers, with an optional step as third number.
|
|
Function input/parameters: argc and argv command line parameters
|
|
Function output/parameters: NONE
|
|
Function output/returned: NONE
|
|
Device input/---: NONE
|
|
Device output/---: NONE
|
|
Dependencies: included by standard libraries
|
|
*/
|
|
int main(int argc, char *argv[])
|
|
{
|
|
// check if proper arguments are provided
|
|
if (argc < 3 || argc > 4)
|
|
{
|
|
printf("You must provide two or three integers.\n");
|
|
return 0;
|
|
}
|
|
// define the start and stops, steps if applicable
|
|
double start = atof(argv[1]);
|
|
double stop = atof(argv[2]);
|
|
int step = 1;
|
|
if (argc == 4)
|
|
{
|
|
// define the step if provided.
|
|
step = atoi(argv[3]);
|
|
}
|
|
for (start = atof(argv[1]); start <= stop; start += step)
|
|
{
|
|
// print out the temperature chart
|
|
printf("%g\t%f\n", start, (start - 32) * 5 / 9);
|
|
}
|
|
// end program
|
|
return 0;
|
|
} |