1. ## Fibonacci

Hi Guys I am fairly new to C++ and although I have been doing pretty well, I am now stuck on a certain code.

The problem given to us is stating :

Write a C++ Program that outputs the Fibonacci numbers that are less than a user specified value. Each Fibonacci number is the sum of its two predecessors. The first two Fibonacci numbers are are 1 and 1. Thus, the sequence begins with;
1, 1, 2, 3, 5, 8, 13, 21, 34,  and so on.
The program should keep asking the user for an upper limit and display the Fibonacci numbers that re less than that upper limit until the user enters an upper limit of 1 or less to quit
Output each Fibonacci number on a separate line.

I have been working on this for a while now and so far, this is what I have come up with. I know its not much, but I am trying my hardest to work on it.

Code:
```#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main()
{
int fib;
int fib1 = 0;
int fib2 = 1;
int fib3;
int number;```

Now i understand what the problem is asking for, I just don't know how to program it...This is due tomm, in around 23 hours and I would like to turn it in Thank You!  2. Keep in mind that this forum (and, thankfully, every other programming forum I've ever seen) has (i) strict rules against doing homework assignments for people and (ii) users who basically always follow that rule, so we can only give you "general guidance", although if you have specific problems (e.g. I don't know why this line segfaults/this function doesn't return the value I expect) we'll be happy to help.

Anyway, what's your specific problem - what exactly are you having problems with? Getting user input? How to compute a Fibonacci number? How to structure your program? 3. Oh I'm sorry, I wasn't asking anyone to do my homework...I was just hoping that someone would be able to guide me in the right direction...if someone else does my homework, then I don't really learn and I want to learn. My first question is how would I set a limit so that say, if I want a limit of 30, my output should be 1 1 2 3 5 8 13 21. I'm not exactly sure how to set it as.

Code:
```int fib, fib1, fib2, fib3, fibn;

cout << "Please enter an upper limit (1 or less to quit) \n" << endl;
cin >> fibn;``` 4. ## Fib

Oh I'm sorry, I wasn't asking anyone to do my homework...I was just hoping that someone would be able to guide me in the right direction...if someone else does my homework, then I don't really learn and I want to learn. My first question is how would I set a limit so that say, if I want a limit of 30, my output should be 1 1 2 3 5 8 13 21. I'm not exactly sure how to set it as. 5. I'm thinking using an array would be the easiest way for accessing the numbers so often in the same group. As for the max number I'm thinking a Do..While loop would work. I'm just a novice when it comes to C++ but from what I gathered that should work. I'm actually going to try and make this now just to see if I can. Thanks for the challenge. 6. You don't need an array since you can just output the sequence from scratch each time on demand, but it does make sense to use an array to cache the part of the sequence that was previously generated. 7. ## Fib

We actually haven't even learnt arrays yet "/ We JUST Started learning loops and thats it. I'm completely lost in loops, so I'm trying to make this program blind. 8. Originally Posted by Pookie
We actually haven't even learnt arrays yet
Okay, then the "output the sequence from scratch each time on demand" approach is the way to go for you. Originally Posted by Pookie
We JUST Started learning loops and thats it. I'm completely lost in loops
Start by writing a program to compute and print say, the first 10 Fibonacci numbers. 9. A start might also be to write, say, a program that outputs all odd numbers up to users input. Popular pages Recent additions 