diff --git a/Homework3/fibonacci b/Homework3/fibonacci new file mode 100755 index 0000000..19307b1 Binary files /dev/null and b/Homework3/fibonacci differ diff --git a/Homework3/fibonacci.c b/Homework3/fibonacci.c new file mode 100644 index 0000000..bd8bb1b --- /dev/null +++ b/Homework3/fibonacci.c @@ -0,0 +1,56 @@ +// header files +#include +#include +#include +#include + +// local constants + +/* +Name: Fibonacci Sequence +Process: Accepts single integer, prints out up to nth term of the sequence. +Function input/parameters: argc and argv command line arguments +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[]) +{ + // define local variables + int fibonacciNumber = 0; + int prevFibonacciNumber, prevPrevFibonacciNumber; + int fibN1 = 0, fibN2 = 1; + int nthTerm = atoi(argv[1]); + int counter; + // do calculations + if(argc == 2 && nthTerm >= 0) + { + // check to see if the correct number of arguments are included + // fibonacci sequence loop until n. + fibonacciNumber = fibN1 + fibN2; + prevFibonacciNumber = fibonacciNumber; + fibonacciNumber = fibN2 + prevFibonacciNumber; + prevPrevFibonacciNumber = prevFibonacciNumber; + prevFibonacciNumber = fibonacciNumber; + for(counter = 0; counter < nthTerm - 2; counter++) + { + // get the next fibonacci number + fibonacciNumber = prevPrevFibonacciNumber + prevFibonacciNumber; + prevPrevFibonacciNumber = prevFibonacciNumber; + prevFibonacciNumber = fibonacciNumber; + } + printf("The %dth term of the Fibonacci Sequence is: %d\n", nthTerm, prevPrevFibonacciNumber); + } + else + { + // fail program + printf("Please provide one integer greater than zero.\n"); + return -1; + } + // display results + // done in do calculations + // return success + return 0; +} \ No newline at end of file diff --git a/Homework3/jump_the_five.c b/Homework3/jump_the_five.c new file mode 100644 index 0000000..e9bdf93 --- /dev/null +++ b/Homework3/jump_the_five.c @@ -0,0 +1,26 @@ +// header files +#include +#include +#include +#include + +// local constants + +/* +Name: Jump the Five +Process: Takes in 7 or 10 numbers, and applies a transformation to the numbers. +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[]) +{ + // define local variables + // do calculations + // display results + // return success + return 0; +} \ No newline at end of file diff --git a/Homework3/temperature_chart.c b/Homework3/temperature_chart.c new file mode 100644 index 0000000..0c03826 --- /dev/null +++ b/Homework3/temperature_chart.c @@ -0,0 +1,53 @@ +// header files +#include +#include +#include +#include + +// 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[]) +{ + // define local variables + double start = atof(argv[1]), stop = atof(argv[2]); + int step = 1; + int tempIterator; + // do calculations + if(argc == 3 || argc == 2) + { + // do the temperature chart stuff here + // check to see if a step is provided + if(argc == 3) + { + step = atof(argv[3]); + } + // do the printing and looping + printf("%f\t%f\n", start, start); + for(tempIterator = 0; tempIterator < stop; tempIterator++) + { + // print out the temp and it's conversion + printf("%f\t%f\n", ); + } + } + else + { + // fail program + printf("Please provide two or three integers.\n"); + return -1; + } + // display results + // done in do calculations + // return success + return 0; +} \ No newline at end of file