Saturday, September 2, 2017

Fibonacci Numbers in C++

Here is a very simple program that will ask the user to give a number and then our program will generate the fibonacci series of numbers using C++ as our programming language.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.




Program Listing


#include <iostream>

using namespace std;


int main()
{
int x=0,y=0,i=0, n=0 ,sum=0;

cout << "===== FIBONACCI NUMBERS IN C++ =====";
cout << "\n\n";
cout<<"Give a Number : ";
cin>>n;
cout<<"Fibonacci Series is : "<<"\n";
x=0;
y=1;
cout<<x;
cout << "\n\n";
cout<<y;
for(i=3;i<=n;i++)
{
sum=x+y;
cout<<sum<<"\n";
x=y;
y=sum;
}
cout << "\n\n";
cout<<"End of Program";
cout << "\n\n";
}












No comments:

Post a Comment