0

I need some guidance formulating a Do, For, While output using a Fibonacci sequence. After searching the foums I only saw posts that had just the sequence of numbers outputed like so:

01123453 after a set number was preset.

I need the output to display like so:

0 +1 = 1

1 +1 = 2 and so on (dependent on what number of iterations the user selects. Any suggestion would be thankful.

```
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int choice; // Menu choice
int number; // Number of iterations
int fib, fib1, fib2; // Possible equation variables
// Display the menu and get a choice.
cout << "Please enter the number of your selection ";
cin >> choice;
cout << "0. Exit Program\n";
cout << "1. Fibonacci For\n";
cout << "2. Fibonacci Do\n";
cout << "3. Fibonacci While\n\n";
// Respond to the user's menu selection.
if (choice == 1)
{
cout << "How many iterations of the number do you want to see? ";
cin >> number;
cout << fib1 << + << fib2 << = << fib << endl;
}
else if (choice == 2)
{
cout << "How many iterations of the number do you want to see? ";
cin >> number;
cout << fib1 << + << fib2 << = << fib << endl;
}
else if (choice == 3)
{
cout << "How many iterations of the number do you want to see? ";
cin >> number;
cout << fib1 << + << fib2 << = << fib << endl;
}
else if (choice == 0)
{
cout << "Program ending.\n";
}
else
{
cout << "The valid choices are 0 through 3. Run the\n";
cout << "program again and select one of those.\n";
}
return 0;
}
```