Monday, 13 July 2015

Write a C Program To Print Fibbonacci Series

1:  #include<stdio.h>  
2:  int main()  
3:  {  
4:    int n, first = 0, second = 1, next, c;  
5:    printf("Enter the number of terms\n");  
6:    scanf("%d",&n);  
7:    printf("First %d terms of Fibonacci series are :-\n",n);  
8:    for ( c = 0 ; c < n ; c++ )  
9:    {  
10:     if ( c <= 1 )  
11:       next = c;  
12:     else  
13:     {  
14:       next = first + second;  
15:       first = second;  
16:       second = next;  
17:     }  
18:     printf("%d\n",next);  
19:    }  
20:    return 0  

No comments:

Post a Comment