Asked
Active
Viewed 82 times
-6
-
there are cases in which you don't change the value of x. – Stultuske Mar 21 '16 at 12:49
-
so does it have to leave while loop for x before it can leave the one for i? – Jake Mar 21 '16 at 12:51
-
3First: you should not post the whole message of your post as a link and second: you can put source code directly into your post (without using an external image). That would make it even easier to read your question and your code simultaneously. ;-) – Alex Mar 21 '16 at 12:55
-
Please format question better. – K.Nicholas Mar 21 '16 at 13:00
-
You should check your outer `else` statement. Either this would cause your inner loop to run forever (it does not change the value of `x`) or crash your application (negative index). – Alex Mar 21 '16 at 13:01
1 Answers
-1
I am assuming that you are new to programming because you are using BlueJ. When your second loop is running, I'm guessing that your line x=x is keeping x within range and hence the loop never exits.
One good thing to help is to use a debugger or print statements to show what the values of x and i are at each stage. That will quickly let you know what is going wrong.
![](../../users/profiles/5270540.webp)
dilbert
- 41
- 1
- 5
-
-
User asked why program was not leaving the loop. My answer was stating because x was staying within range. – dilbert Mar 22 '16 at 07:31