0
Why isn't my code printing 5 and going up 1 each time until it is 10?
1 Answer
+ 1
I've spotted two problems:
1) You've declared int 'a' twice. Once at the top (line 4) and again during the while loop (line 10). You need to remove the 'int' declaration on line 10.
Once you do that, you'll notice it prints: 5 5 6 7 8 9
That brings us to the second problem:
2) You want <= instead of just <. Otherwise, the loop will not print out 10. It would stop at 9, and once a becomes 10, the loop would cease to run with just "<". OR you could make it a < 11, though I prefer the first option.