Search here

Pages

Saturday, August 13, 2011

Fibonacci Series printing using Functions

#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
void fibonacci(int );
void main()
{
int n;
clrscr();
cout<<"Enter a digit to findout fibonacci around it's range";
cin>>n;
fibonacci(n);
getch();
}
void fibonacci(int x)
{
int a=0,b=1,c;
cout<<a<<"\t"<<b;
while(c<x)
{
c=a+b;
a=b;
b=c;
cout<<"\t"<<c;
}
}
 

0 comments

Post a Comment