Write a C++ Program to Generate Fibonacci Series for N numbers. Here’s simple Program to Generate Fibonacci Series for N numbers in C++ Programming Language.
Fibonacci Series is in the form of 0, 1, 1, 2, 3, 5, 8, 13, 21,…… To find this series we add two previous terms/digits and get next term/number.
Here is source code of the C++ Program to Generate Fibonacci Series for N numbers. The C++ program is successfully compiled and run(on Codeblocks) on a Windows system. The program output is also shown in below.
SOURCE CODE : :
/* C++ Program to Generate Fibonacci Series for N numbers */
#include<iostream>
using namespace std;
int main()
{
int i,no, first=0, second=1, next;
first=0;
second=1;
cout<<"How many terms u want to Display :: ";
cin>>no;
cout<<"\nThe Fibonacci series for [ "<<no<<" ] terms are :: \n\n";
for(i=0; i<no; i++)
{
cout<<" "<<first<<" ";
next = first + second;
first = second;
second = next;
}
cout<<"\n";
return 0;
}
Output : :
/* C++ Program to Generate Fibonacci Series for N numbers */
How many terms u want to Display :: 8
The Fibonacci series for [ 8 ] terms are ::
0 1 1 2 3 5 8 13
Process returned 0
Above is the source code for C++ Program to Generate FibonacciSeries for N numbers which is successfully compiled and run on Windows System.The Output of the program is shown above .
Fibonacci Series is in the form of 0, 1, 1, 2, 3, 5, 8, 13, 21,…… To find this series we add two previous terms/digits and get next term/number.
Here is source code of the C++ Program to Generate Fibonacci Series for N numbers. The C++ program is successfully compiled and run(on Codeblocks) on a Windows system. The program output is also shown in below.
SOURCE CODE : :
Output : :
Above is the source code for C++ Program to Generate FibonacciSeries for N numbers which is successfully compiled and run on Windows System.The Output of the program is shown above .
need an explanation for this answer? contact us directly to get an explanation for this answer