# C++ | Fibonacci Series

Introduction

This is a tutorial for the most famous Fibonacci series in C++. The program just asks of how many number to print. The program is not extendable. Go enjoy the program. Lets begin…..

Program for Fibonacci Series in C++.

``````#include<iostream.h>
#include<conio.h>
void main()
{
//clear the screen.
clrscr();
//declare variable type int
int no1=0,no2=1,no3,n;
//Input the numbers
cout<<"How many numbers of fibonacci series do you want?"<<endl;
cin>>n;
//The fibonacci series
cout<<"Here we go..."<<endl;
//Print first two numbers manually
cout<<no1<<endl;
cout<<no2<<endl;
for(int i=0;i<n-2;i++)
{
no3=no1+no2;
no1=no2;
no2=no3;
cout<<no3<<endl;
}
//get character
getch();
}``````

Output

How many numbers of fibonacci series do you want?
7
Here we go…
0
1
1
2
3
5
8

How does it work.

1. You enter the number of numbers you want.
2. The number is generated and printed.

Extending it.

The program is not extendable.

Explanation.

1. Include ‘iostream.h’ and ‘conio.h’ files.
3. Start program by first clearing the screen.
4. Declare variables.
5. Add cout and cin to get number.
6. Manually print first two numbers.
7. Add a loop to calculate and print the number.
8. Get character.

At the end

You learnt creating the C++ program for Fibonacci Series. So now enjoy the program.