Wednesday, October 19, 2011

Program: To print Fibonacci series




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();
}

Article by
Chief-Editor

He is a tech Enthusiast, an Altruist and calm mentor. He loves to code. He is also a creative graphic designer. Do check out his designfolio @ Jasmeet.asia If you like This post, you can follow me on Twitter.



For Further Reading,
C++ Program, Control Structures

0 comments:

Post a Comment