To See Your Program In Fibonacci Series In C

  1. int main()  
  2. {  
  3.    int n, first = 1, second = 1, next, c;  
  4.    
  5.    printf("Enter the number of terms\n");  
  6.    scanf("%d",&n);  
  7.    
  8.    printf("First %d terms of Fibonacci series are :-\n",n);  
  9.    
  10.    for ( c = 1 ; c < n ; c++ )  
  11.    {  
  12.       if ( c <= 1 )  
  13.          next = c;  
  14.   
  15.       else  
  16.       {  
  17.          next = first + second;  
  18.          first = second;  
  19.          second = next;  
  20.       }  
  21.       printf("%d\n",next);  
  22.    }  
  23.    
  24.    return 0;  
  25. }  
  26. output
  27. n=5
  28. fibonaaci series
  29. 1
  30. 1
  31. 2
  32. 3
  33. 5