im working on this modified fibianoci problem for class and although i cant ever spell fibinoci right
I did manage to work out the function as my teacher has requested.
unforutnetly when i put the finishing touches on the code and added a while loop so the user could exit by typing -1 i am presented with an infinite loop of seemingly random numbers.
I assume Im missing a bracket somewhere but i just cant find it.
thoughts?
hints?
suggestions?
thank you to everyone
Expand|Select|Wrap|Line Numbers
- #include <stdio.h>
- #include <math.h>
- // This is Lab4Part1
- // 998275842
- // Houston Keil-Vine
- // Creates a sting of numbers
- // using the previous 2 numbers.
- int main (void)
- {
- int f3=1;
- int f2=0;
- int f1=1;
- int f4=1;
- int n=0;
- int counter=0;
- printf("Enter a non-negative integer or enter -1 to quit:\n");
- scanf("%d",&n);
- while(n>0) {
- for(counter=0; counter<=n; counter++)
- {
- printf("%d ",f4);
- f4=f1+f2;
- f1=f2;
- f2=f3;
- f3=f4;
- }
- printf("\n");
- }
- return 0;
- }