If you are a Math enthusiast, I'm sure that you have heard about the mighty and mysterious Fibonacci Series. It is as difficult as understanding it, to understand its implementation in a programming language. But the program is surprisingly simple! I'm not going to explain the working, because, it is complicated. But if you have a good logical quotient, you can understand it with ease. Such a program is one of a kind. So just keep at it to understand it!
Here is the code
For newer IDEs, visit this page.
Here is the code
/*Support us by subscribing, commenting, and viewing<br> the blog frequently! -GeekyCircle Admin :)*/
#include<iostream.h>
#include<conio.h>
void main()
{
long int first_no = 0, sec_no = 1, counter, next_term, no_of_terms;
cout<<"Enter the number of terms you want : ";
cin>>no_of_terms;
cout<<"\nRequired series is : "<<endl;
for(counter = 0; counter < no_of_terms; counter++)
{
if(counter<=1)
{
next_term = counter;
}
else
{
next_term = first_no + sec_no;
first_no = sec_no;
sec_no = next_term;
}
cout<<next_term<<"\t";
}
getch();
}
For newer IDEs, visit this page.
No comments:
Post a Comment