Saturday, June 29, 2013

Write a program to print the Fibonacci series ?

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

void main()
{
int n1=0,n2=1,n,sum=0;
clrscr();
printf("\nEnter the limit of the series");
scanf("%d",&n);
printf("\n%d",n1);
printf("\n%d",n2);
while(sum<n)
{
sum=n1+n2;
n1=n2;
n2=sum;
printf("\n%d",sum);
}
getch();
}

Output:
image
What is Fibonacci series ?
the series which is obtained by addition of two previous no is called Fibonacci series.

Like the Post? Do share with your Friends.

1 comment: