Saturday, January 26, 2013

C++ Program to show Fibonacci Series

Fibonacci


Write a program , that prints all the Fibonacci numbers ,which are smaller than or equal to a number k(k≥2) ,which was entered by the user.
The Fibonacci numbers are a sequence of numbers,where then-th number of Fibonacci is defined as:
Fib(0)=0,
Fib(1)=1,
Fib(n)=Fib(n-1)+Fib(n-2) Usage :> Input of k:21 > Fibonacci numbers<=21:01123581321

Solution-


#include<iostream>

using namespace std;


 int main (void)
{
     
    int r=0,a=0,n,b=1,i,c;
    char redo;
    do
    {
         a=0;
         b=1;
     cout<<"enter the the value of n:";
     cin>> n;
     if(n>100){
     cout<<"enter some lessor value"<<endl;
     }
     else{
     cout<<a<<endl;
     for (i=0;i<=n;i++)
     {
     c=a+b;
     a=b;
     b=c;
     cout<<"serial no."<<i+1<<"==";
     cout<<a <<endl;
}     
      cout<<"enter y or Y to continue:";
           cin>>redo;
           cout<<endl<<endl;
}
           }
           while(redo=='y'||redo=='Y');
    
   
   system("pause");
    return 0;
}  


   

C++ program Fibonacci series



---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------




---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------


Fibonacci sequence in c++
Fibonacci Series - C / C++
c++ program to generate Fibonacci series
Fibonacci numbers c++
C++ Fibonacci program
How do i write a c++ code for a fibonacci sequence
Write the program for fibonacci in c++?
C++ Program to print the Fibonacci Sequence!
Write a program to implement the Fibonacci series

2 comments:

  1. C++ Program to Generate Fibonacci series

    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.

    ReplyDelete