Lab 6 Source Code

Either cut-and-paste the following into your lab, or

lab6-1.c

#include <stdio.h>
#include <math.h>

int main(void) {
int fib, fibOld, fibOld2, count;
double golden, goldenOld;

/*fib = 1;
fibOld = 1;
golden = 1.0;*/

printf("n\t Fn\tGolden ratio\n");

for (count = 1; count<29; ++count)
printf("*");

printf("\n");

do {
fibOld2 = fibOld;
fibOld = fib;
fib = fibOld + fibOld2;
goldenOld = golden;
golden = fib / fibOld;
printf("%3d\t%3d\t%.4f\n", count, fib, golden);
} while (fabs(golden - goldenOld) > 0.0001);

return(0);
}