Advertisement
sujonshekh

fibonacci

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