Created
January 26, 2013 13:07
-
-
Save sprintr/4642281 to your computer and use it in GitHub Desktop.
Prints Fibonacci series
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That is whta i have searching for.
By the way thanx very much.