Wap to print Fibonacci series
code:
#include<conio.h>
#include<iostream.h>
void main()
{
clrscr();
int n;
cout<<"enter the last limit for the series(>2)";
cin>>n;
int a=1,b=1,c=0;
cout<<a<<"\n"<<b<<"\n";
for(int i=1;i<=n-2;i++)
{
c=a+b;
cout<<c<<"\n";
a=b;
b=c;
}
getch();
}
For Further Reading,
0 comments:
Post a Comment