How to Find Even Numbers in Fibonacci Numbers Sequence

This C++ program is about Fibonacci number sequence. The Program calculate the even number in Fibonacci series and also calculate their sum.

Source Code 

#include <iostream>
using namespace std;

/*Uzair*/

void welcomeScrean(void);
void evenFibonacci(void);

int main()
{
 system ("color F0");
 
 welcomeScrean();
 
 evenFibonacci();
 system("pause");
    return 0;
}

void welcomeScrean(void){
  cout<<"\a"
  <<"\t*******************************************************"<<endl
  <<"\t**                                                   **"<<endl
  <<"\t**                   Welcome To                      **"<<endl
  <<"\t**                                                   **"<<endl
  <<"\t**               Find Even Fibonacci                 **"<<endl
  <<"\t**                                                   **"<<endl
  <<"\t**                 and there sum                     **"<<endl
  <<"\t**                                                   **"<<endl
  <<"\t**                 Program By LEP                    **"<<endl
  <<"\t**                                                   **"<<endl
  <<"\t*******************************************************"<<endl
  <<endl
  <<endl;
}

void evenFibonacci(void){
 

 int num,count=0;
    long previous =1, next =0,sum;
    cout<<"\t Enter Your Number to Find Fibonacci ";
    cin>>num;

 cout<<"\n\t First "<<num<<" Even Fibonacci Numbers Are \n";
    
 do{
  if(previous%2==0){
      cout<<"\n\t "<<previous<<" ";
      count++;
  }
        sum = previous+next;
        next = previous;
        previous = sum;
        
    }while(count!=num);
    
}

Output of the Program

how to find fibonacci numbers

Share on Google Plus

About Asad

Asad Niazi is Software Engineer , Programmer, Web Developer and a young mentor of BloggersTown and PProgramming. Asad Love to writes about Technology, Programming, Blogging and make money online.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment