Today we are going to write a program for Fibonacci series in c++ language which is very simple.We are going to use classes and functions in our program.BY definition Fibonacci series start’s by 0 and 1,from then,if we need a number in the series then we need to add two numbers which are previous to our required number position.i.e If we need to get the third number then we must add first and second numbers.In the series first and second numbers are 0 and 1.Hence the third number will be 0+1=1.By this way we can find the numbers in the series.Let us write the code for the program…

#include<iostream.h>
#include<conio.h>
class fib
{
public:
int a,b,c;
void generator(int);
};
void fib::generator(int n)
{
a=0,b=1;
cout<<a<<" "<<b;
for(int i=1;i<=n-2;i++)
{
c=a+b;
cout<<" "<<c;
a=b;
b=c;
}
}
void main()
{
clrscr();
int n;
cout<<"Enter number of terms you need in the series:";
cin>>n;
fib ob;
ob.generator(n);
getch();
}

**Output:**

You can download the source code:download

### Like this:

Like Loading...

*Related*

## About Anuroop D

Very enthusiastic about technology and likes to share my knowledge through blogging. Has Bachelor's in Information Technology and currently pursuing my Master's in Computer Science.

hey great post…..