Skip to content

Instantly share code, notes, and snippets.

@sprintr
Created January 26, 2013 13:07
Show Gist options
  • Save sprintr/4642281 to your computer and use it in GitHub Desktop.
Save sprintr/4642281 to your computer and use it in GitHub Desktop.
Prints Fibonacci series
#include <iostream.h>
void main(void)
{
int numberTerms = 0, fNumber = 0, sNumber = 1, nNumber = 0;
cout << "Enter the number of terms: " << endl;
cin >> numberTerms;
cout << "The terms in this series: " << endl;
int i;
for(i = 1; i <= numberTerms; i++)
{
nNumber = fNumber + sNumber;
fNumber = sNumber;
sNumber = nNumber;
}
cout << nNumber << endl;
}
@MuhammadAAbi
Copy link

That is whta i have searching for.
By the way thanx very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment