Here's one of the quiz questions from this site:
"What is the final value of x when the code for(int x=0; x<10; x++) is run?"
Why is the answer 10? It clearly says "x < 10" in the for loop. I'm pretty sure 10 isn't less than 10.
Here's one of the quiz questions from this site:
"What is the final value of x when the code for(int x=0; x<10; x++) is run?"
Why is the answer 10? It clearly says "x < 10" in the for loop. I'm pretty sure 10 isn't less than 10.
Here's a walkthrough.
Thus, at the end of the loop, x == 10.Code:x=0; x<10? yes add 1 to x x<10? yes(x=1) add 1 to x x<10? yes(x=2) ... add 1 to x x<10? yes(x=9) add 1 to x x<10? no(x=10) loop done
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
because the loop doesnt stop until the midlle condition is no longer true. At 9, the condition is still true so it iterates and then increments x (so x is now 10), then checks the condition, sees that x is no longer less than 10, and exits the loop. Get it?