--A fibonacci sequence is difined as follows: the first and second term in the sequence are 0 and 1. Subsequent terms are found by adding the proceeding two terms in the sequence.
#include(iostream.h)
#include(conio.h)
void main( )
{
int f=0, s=1, t, n, ct;
clrscr( );
cout<<"Enter the no. of terms:";
cin>>n;
cout<<"Fibonacci series:";
cout<< f << s;
for( ct=3; ct<=10; ct++)
{
t=f+s;
cout<< t;
f=s;
s=t;
}
getch( );
}
Here 'f' means 'first' 's' means 'second'
't' means 'third'
'ct' means 'count' the displayed numbers.
Output:- Enter the no. of terms: 10
The Fibonocci series:
0 1 1 2 3 5 8 13 21 34
Note:- If u have any doubt regarding this program or logic, please feel free to contact me.
Tuesday, February 24, 2009
Subscribe to:
Post Comments (Atom)
what are f s t here in tis problem?
ReplyDelete