Pages

Friday 18 March 2011

PROGRAM OF FIBONACCI SERIES

DESCRIPTION-:This program display the Fibonacci series.A fibonacci series is one in which first term is 0 and second term is 1 and the next term is the sum of the two previous term and so-on.
This program display the Fibonacci series according to the users requirement OR upto user entered number.
FOR EXAMPLE-: If the user enter a number 5

then it generate fibonacci series as------
                        0    1    1    2    3    5    8

PROGRAM-:
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n,i,first=0,second=1,third;
cout<<"how many no u want to print";
cin>>n;
cout<<"fibonacci series"<<"\n";
cout<<first<<" "<<second<<"\n";
for(i=2;i<=n;i++)
{
third=first+second;
cout<<third<<"\n";
first=second;
second=third;
}
getch();

}

0 comments:

Post a Comment

 
Copyright (c) 2010 Concepts Of C++. Design by WPThemes Expert

Blogger Templates and RegistryBooster.