Friday, 23 May 2014

FIBONACCI SERIES in C++

Program: 
#include<iostream.h> 
#include<conio.h> 
void main() 
{ 
int a=0,b=1,c,d; 
clrscr(); 
cout<<"Enter the number"<<endl; 
cin>>d; while(d>=1) 
{ 
c=a+b; a=b; b=c; d=d-1; 
cout<<c<<endl; 
} 
getch(); 
}

OUTPUT: 
Enter the number 
6 
1
2 
3 
5 
8 
13

No comments:

Post a Comment