Tuesday, 9 December 2014

C Program to print Fibonacci series

Program to print Fibonacci series
#include<stdio.h>
#include<string.h>
main()a
{
int a=0,b=1,c=0,n;
printf("enter value for n");
scanf("%d",&n);
printf("%d %d ",a,b);
while(n>c)
{
c=a+b;
printf(" %d",c);
a=b;
b=c;
}
printf("\n");
}
OutPut:
enter value for n:
9
0 1 1 2 3 5 8 13