I have this Fibonacci program due this Friday. I can't figure out what to put into the for loop to find the term requested by user. Here is what the program should do:
What term would you like to see?
4
The term you requested is 3. Thanks.
Press any key to continue...
#include <iostream>
usingnamespace std;
int main()
{
int Term = 0;
int Fibonacci = 0;
int TermRequest = 0;
int Number1 = 0;
int Number2 = 0;
cout << "What term do you want to see: ";
cin >> Term;
for(int x = 0; x > 0; x++)
{
}
cout << "The term you request is " << Request << endl << endl;
system("PAUSE");
return 0;
}
#include <iostream>
usingnamespace std;
int main () {
int temp;
int num1 = 0;
int num2 = 1;
int count = 0;
cout << "Enter in the number of iterations for the"
<< " fibonacci sequence\n";
cin >> count;
if (count == 1) {
cout << 0;
}
cout << 0 << ", ";
for (int i = 1; i < count; i++) {
temp = num1+num2; //swap procedure
num1 = num2;
num2 = temp;
cout << num1 << ", ";
}
return 0;
}
sorry about how poorly this is written I have to go to work in a minute, but this is a working program and should adequately show you how the fibonacci formula really works.