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); }
0 comments:
Post a Comment