From aae5754baa94a9afb887c5fd999908ee0c18a88c Mon Sep 17 00:00:00 2001 From: cdez Date: Sun, 22 Oct 2023 14:53:37 -0700 Subject: [PATCH] Started Homework 3 ++ Fibonacci ++ Jump the Five ++ Temperature Chart --- Homework3/fibonacci | Bin 0 -> 16048 bytes Homework3/fibonacci.c | 56 ++++++++++++++++++++++++++++++++++ Homework3/jump_the_five.c | 26 ++++++++++++++++ Homework3/temperature_chart.c | 53 ++++++++++++++++++++++++++++++++ 4 files changed, 135 insertions(+) create mode 100755 Homework3/fibonacci create mode 100644 Homework3/fibonacci.c create mode 100644 Homework3/jump_the_five.c create mode 100644 Homework3/temperature_chart.c diff --git a/Homework3/fibonacci b/Homework3/fibonacci new file mode 100755 index 0000000000000000000000000000000000000000..19307b18a105edad38eb6c938e85471733106290 GIT binary patch literal 16048 zcmeHOYitzP6~4RXVZy`a)fi}D(j;xu#EWf=1yn8z_L?y=;DW6tQqy7V9ecOhhqF5y zY!nhIH&HhZ68+JqT8Z{YLY4kNYNb-CQjKVE(wB^?O0-Q{8i8aQ+8RPqrzLE^Gjq-| zo~)@9rTsP6n*Hwi&g0%Wb7y^L=iaAcT^-?2NJ*(upH?KDsCAhrE2dkx0*IZ2||>y``Q*;vhd6_EVus8Rtx?9xh5dPqoqbCqvUhfo9+p9lHPCk4xX zEO0*sMPF`DBWD!N`7C1>8K4My{irJ^>m9W^**Y5&+};qQ_>o9{r`hi``w32SdxDZr z$_X7?IG=uOfR2iw-!H*_er$K$lpwW1<-lb-{(jo)X1|2ygi(HMc4;Lj?R^G*d}-O@ z&LEe0Kesp6b$FQbFUaXt8&k=?mgbGAczr6FDGb*SZ)vG-X^!NxktU~M>X(Lt#?-F8 zy$WH*iQ_b?@KINmc%)m!db0oL>1}WATXe|2`Te?km%X-l}gA7Gggn;m!kNC>1>AM8?I?Z zLv%EZURU9dKIxzm0=o$)|4AjrV~A_H&MtpArjdbL^~oB#WbO6gCJ+u_or zKKk?OvrcoR&Ci0qUb=q_P_sd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-(BZ{7;kqi=E(;@Ta+<$TB|^Y~aTH{g*x*LxplG{xV+`9A`sm z-+%sJXaAjSC-YxH-Q!O=^ZS1n9OXpfm;Zn8{}FjE;4n^KrB3*59A1Bo{RE?A^ey#5DSAt-hdLS(^HKK~(B2sVf#qxcE_#OHs46@nAgIZqKkp?-#nxBoJq5tQdH zvG?CUFR{N|f2FY{;{b~Sa{Wa9H7eA;_$M@1BiQVUS2r0%zi+eVGT=vcKP+ z+VYm=+&-I^RpS3(nQ<%P??o9qUehQCJkA~a2$b|)DE*P|-$mf0?_U2&dhkN2@&%W6 VU9J1LR>}Xjn_Y{wJ_nzu{sZ4Fh?4*S literal 0 HcmV?d00001 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