View Single Post
  #1 (permalink)  
Old February 22nd, 2004, 02:54 PM
amahja56 amahja56 is offline
Authorized User
 
Join Date: Jan 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default help please if u can

hello everybody....i have a question about the following code...its about fibonacci series...

# include <iostream.h>
# include <conio.h>

int main()
{
clrscr();

int n,i,c;
int a=0;
int b=1;
cout<<"Enter number of terms:";
cin>>n;

cout<<"\n"<<a<<""<<b;
for(i=2;i<n;i++)
{
c=a+b;
cout<<""<<c;
a=b;
b=c;
}
getch();
}

my question is in the part of :
 for(i=2;i<n;i++)
{
c=a+b;
cout<<""<<c;
a=b;
b=c;
}

i couldnt get the logic of this part....so can any pne explain to me please...?


Note: sorry if the question may look stupid..but im a beginner in c++.


Reply With Quote