MY mENU


Wednesday 21 March 2012

Fibonacci Series c language

Fibonacci Series c language 

 #include
    main() {
        int n, first = 0, second = 1, next; 
           printf("Enter the number of terms\n");
              scanf("%d",&n);
                printf("First %d terms of Fibonacci series are :-\n",n); 
                   for ( int i = 0 ; i< n ; i++ ) { 
                      if ( i<= 1 ) 
                       next = i; 
                         else { 
                           next = first + second; 
                             first = second; 
                               second = next; 
                                 } 
                         printf("%d\n",next); 
                  } 
          return 0; 
    }

No comments:

Post a Comment