A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

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

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

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)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now