SyntaxFix
Write A Post
Hire A Developer
Questions
I suggest you step through the code in your debugger as debugging programs is what it is for.
What I would expect you would see is that every time the code loops int x = 0; is set.
int x = 0;