diff --git a/assignment5.txt b/assignment5.txt new file mode 100644 index 0000000..0c289f0 --- /dev/null +++ b/assignment5.txt @@ -0,0 +1,15 @@ +Ava N. +July 5, 2016 +Assignment 5 + +1. I would call int fxn(int a, float b, int c) by: +main(){ + int a, c; + float b; + int fxn(int a, float b, int c) + return 0; +} + +2. Recursion is when a function calls itself. Iteration is the repitition of a process or something, which can also be refered to as a loop. The best process to use, whether it is recursion or iteration depends on the circumstance. Iteration keeps going until the loop is complete while recursion solves a problem one at a time. Recursion is worse in other cases because it takes up more space and time... + +3. A compiler works by taking 'High-level language' such as C, C++, and Java, and putting it through a compiler (gcc) to make an assembly. diff --git a/loop b/loop new file mode 100755 index 0000000..165a11d Binary files /dev/null and b/loop differ diff --git a/loopFibonacci.c b/loopFibonacci.c new file mode 100644 index 0000000..cb36d9f --- /dev/null +++ b/loopFibonacci.c @@ -0,0 +1,30 @@ +/*Ava N.*/ +//fibonacci sequence as a loop +#include +#include + +int main(){ + int input; + int num1=0; + int num2=1; + int answer; + int counter; + + printf("Enter the number of terms\n"); + scanf("%d", &input); + + printf("Here is the Fibonacci Sequence: \n"); + + for (counter=0; counter +#include + +int fibo(int K){ + if ( K == 0 ){ + return 0; + } + else if ( K == 1 ){ + return 1; + } + else{ + return (fibo(K-1) + fibo(K-2)); + } +} + +int main(){ + int K; + int answer=0; + int counter; + + printf("Type how long you want the fibanocci sequence to be: \n"); + scanf("%d",&K); + + printf("Here is the Fibonacci Sequence: \n"); + + for (counter=1 ; counter<= K ; counter++ ){ + printf("%d\n", fibo(answer)); + answer++; + } +} +