C++ Program:

- To print fibonacci series

Example:

User Input: 5

Output:
Fibonacci series : 0 1 1 2 3 5

#include <iostream>
using namespace std;

int main() {
  int num,a=0,b=1,next;
  cout<<"Enter fibonacci series nth term : ";
  cin>>num;
  cout<<"Your fibonacci series :";

  for(int i=0; i<num; i++) {
    cout<<a<<" ";
    next=a+b;
    a=b;
    b=next;
  }
  return 0;
}

Output:

  Enter fibonacci series nth term : 8
  Your fibonacci series : 0 1 1 2 3 5 8 13
Program
number

You should know first :

Fibonacci Series : Series of numbers in which each number is the sum of the last 2 numbers

//Initially a & b :holds 1st & 2nd terms of fibonacci series
for(int i=0; i<num; i++) {
  cout<<a<<" ";
  next=a+b;
  a=b;
  b=next;
}
Concept

Coming Soon !

Quick
Tutorial

Quote

A good decision is based on knowledge and not on numbers.