Program to Display Fibonacci series in C++.

Fibonacci Series: – is in the form of 0, 1, 1, 2, 3, 5, 8, 13, 21,…… To find this series we add two previous terms/digits and get next term/number.

 

 

Let’s write a program to Display Fibonacci Series in C++.

 

 

Step1: Let’s open turboC++ and write the following Code .

 

 

//Code

 

 

#include<iostream.h>

#include<conio.h>

void main()

{

long int   a,n,c,i,j;

clrscr();

cout<<”enter range of numbers:”;

cin>>a;

cout<<”enter first number:”;

cin>>i;

cout<<”enter second number:”;

cin>>j;

for(n=0;n<=a;n++)

{

c=i+j;

i=j;

j=c;

cout<<”\n”<<c;

}

getch();

}

 

 

 

Step 2: Run the program and see Output.

 

 

Output:

 

 

output

 

Happy Coding.

 

 

 

 

 

 

 

 

 

 

Tags: , , ,