Fibonacci series

#include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
int i,n,first=0, second=1, next;
first=0;
second=1;
cout<<"enter a number for fibonacci series:"; 
cin>>n;
cout<<"fibonacci series :\n";
for(i=0;i<n;i++)
{
cout<<"\n"<<first;
next=first+second;
first=second;
second=next;
}
getch();
}

Result:

Fibonacci Series
Fibonacci Series

Test Yours Self

Value

(Visited 168 times, 1 visits today)
Share with Friends :
Written by:

Leave a Reply

Your email address will not be published. Required fields are marked *