C++ program to find Fibonacci Series


Levels of difficulty: / perform operation:

The Fibonacci numbers or Fibonacci series or Fibonacci sequence has first two numbers equal to 1 and 0 and the further each number is consist of the addition of previous two numbers
1st number = 0
2nd number = 1
3rd number = 0+1= 1
4th number = 1+1= 2
5th number = 1+2= 3
And so on.



C++ Program

#include<iostream>
    using namespace std;
int main() {
	int range, first = 0, second = 1, fibonicci=0;
	cout << "Enter Range for Terms of Fibonacci Sequence: ";
	cin >> range;
	cout << "Fibonicci Series upto " << range << " Terms "<< 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;
}

Other Related Programs in cpp

  1. C++ program to find Fibonacci Series





Quantitative Aptitude
Reasoning
Programming
Interview