for loop

Program that will display sequence
example: 9,8,7,6,5,5,6,7,8,9
that is the output.

There's something wrong with my code:
}
while (fibnum > 0){
current = prev + prev2;
prev = prev2;
prev2 = current;
current++;

cout << "," << fibnum;
cout << endl;
}
kindly help me with this one. thanks
1. Where's the rest of the code? This looks like a small segment.
2. Why are you using a while loop when you've made it clear you need a for loop?
3. What are those variables? What do they do? What are they used for? Why are they called 'fibnum', 'current', 'prev', 'prev2'?
4. Why do you go to the next line after each number?
OP, your name fits you. I have no idea what you're trying to say. Are you trying to output the Fibonacci Sequence? If so, that example output is not the Fibonacci Sequence. Common courtesy in forums is to state what the issue is, not say "There's something wrong".

Also looks like your loop will just run forever. You never alter fibnum, which happens to be your conditional variable.
Topic archived. No new replies allowed.