Monday, 16 March 2015

Program to generete fibonacci series Using C

# include <stdio.h>
# include <conio.h>

void main()
{
int a = -1, b = 1, c = 0, i, n ;
clrscr() ;
printf("Enter the limit : ") ;
scanf("%d", &n) ;
printf("\nThe fibonacci series is : \n\n") ;
for(i = 1 ; i <= n ; i++)
{
c = a + b ;
printf("%d \t", c) ;
a = b ;
b = c ;
}
getch() ;
}

RUN 1 :
~~~~~~~
Enter the limit : 7
The fibonacci series is :
0 1 1 2 3 5 8

No comments:

Post a Comment