What's wrong with this?

1
2
3
4
5
6
7
8
9
10
11
12
13
int x = 0;

while( x <= 0 )
{

cout << x << endl;

if( x == -1 )
cout << "Negative" << endl;

x--;

}


Logic error?
Last edited on
What are you trying to accomplish?
What do you mean won't run? Does it not compile, or does it not do what you want it to do?
I'm told there's a "logic" error.
Last edited on
Well, this loop will certainly go forever. Presumably, this wasn't the goal, which is why I was asking what you are trying to accomplish. It's hard to tell what the logic error is without knowing the goal.
I was given that code and told that there is a "logic" error. That's it, that's all the info I have.
Last edited on
Perhaps the answer is just that: that it is illogical to have a loop go on forever?
Last edited on
Topic archived. No new replies allowed.