Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions assignment5.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Emma Ladouceur

1. In order to call that code you'd have to set it equal to a variable. So

i = fxn

now set the arguments so

i = fxn(1,2,3)

if you have scanned for variables, rather than set those to exact numbers such as 1 2 and 3 you would input those variables, so

i = fxn(var1, var2, var3)

to print that you just use a print statement with i so

printf("%f", i);


2. Recursion goes through the previous numbers in the sequence and can use those whereas iteration is a loop. It will run over the numbers the amount of times you set it to until it breaks whereas iteration has to do with being greater than zero. Iteration is a task that you set whereas recursion combines the results.

3. A compiler breaks the code into a language that the computer understands. First it takes the code and puts it in assembly language. Thats why each language's compiler is different because the language to assembly transition is very specific. THen it takes assembly and translates it to binary which the computer can understand.
Binary file added lc
Binary file not shown.
45 changes: 45 additions & 0 deletions loopFibonacci.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//Emma Ladouceur
//THis is printing out too many terms,

#include <stdio.h>


int main(){

int i, number;

printf("Enter the number of terms you want to see \n");
scanf("%d", &number);
int one =1, zero = 0;

int answer;
int go;
for(i=0; i<number;i++)
{
if(i<=1)
{
answer = i;

}
else
{
answer = zero + one;
zero = one;
one = answer;

}

printf("%d\n", answer);

}

return 0;

}







Binary file added rc
Binary file not shown.
32 changes: 32 additions & 0 deletions recurseFibonacci.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//Emma Ladouceur
//I don't know the fibonacci sequence so while the math for this i believe is incorrect
#include <stdio.h>

int fib(int);

int main(){

printf("Enter a number: \n");

int number, answer;

scanf("%d", &number);

answer = fib(number);

printf("%d\n", answer);


}

int fib(int a){
int num = 1;

if(a==0){
return num;
}

num = (a-1) + (a-2);
return num;

}