Q:

C++ Program To Print The Fibonacci Series Upto Given Number Of Terms

belongs to collection: Loop Programs In C ++Programming

0

Fibonacci Series Program in C++ | In the Fibonacci series, the next element will be the sum of the previous two elements.

The Fibonacci sequence is a series of numbers where a number is found by adding up the two numbers before it. Starting with 0 and 1, the sequence goes 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, and so on…

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include<iostream>
using namespace  std;
int  main()
{
int  range, first  = 0,  second  = 1,  fibonicci;
cout  <<  "Enter the Range for Terms of Fibonacci Sequence "  <<  endl;
cin  >>  range;
cout  <<  "Fibonicci Series upto "  <<  range  <<  " Terms  "<<endl<<  endl;
for  (  int  c  = 0 ;  c  <  range  ;  c++  )
{
if  (  c  <= 1 )
fibonicci  =  c;
else
{
fibonicci  =  first  +  second;
first  =  second;
second  =  fibonicci;
}
cout  <<  fibonicci  <<"  ";
}
return  0;
}

 

Output:

Enter the Range for Terms of Fibonacci Sequence 

8

Fibonicci Series upto 8 Terms  

0  1  1  2  3  5  8  13  

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C++ Program to Sort Elements in Lexicographical Or... >>
<< C++ Program Convert Decimal Number To Binary Numbe...