program to generate Fibonacci Series.


#include<iostream.h>

#include<conio.h>

void main()

{

clrscr();

longint a=0,b=1,c,n;

cout<<"enter any limit=";

cin>>n;

cout<<a<<" " <<b<<" ";

for(int i=3;i<=n;i++)

{c=a+b;

cout<<c<<" ";

a=b;

b=c; }

getch();

}

OUTPUT

enter any limit=20

0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584

Comments :

Post a Comment