Advertisement
sujonshekh

fabonacci while loop

Dec 7th, 2015
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.21 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(){
  4.  
  5. int i,s,a=0,b=1,n,x;
  6.  
  7. printf("Enter a term\n");
  8. scanf ("%d",&n);
  9. printf ("%d\n%d\n",a+b);
  10.  
  11. x= n-2;
  12. while (x-1){
  13.  s=a+b;
  14.  printf("%d\n",s);
  15.  a=b;
  16.  b=s;
  17. }
  18. retrn 0;
  19.  
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement