I want to figure out how this loop sequence how would the computer execute this loop by going through all the steps in the picture attached.

Recommended Answers

All 2 Replies

What do you mean?
That's exactly what happens in order.
1) An initial value is set
2) The framework checks to see if the condition in the middle has been reached
3) Action is taken
4) take action on the counter (in this case -- increment)
5) Is the condition still good?
6) Take action
7) Increment
8) Condition is no longer good
9) Drop out to next level of execution.

commented: Good man +2

1. initialize a counter i and set to 0
2. give a condition: while counter is less than 2
3. while number 2 is true (meaning counter is still less than 2) execute the code inside the curly braces.
4. then increment the counter
5. check if the counter is still less than the 2
6. if it is still true, execute the code inside the curly braces again
7. increment the counter again
8. check the condition if the counter is still less than 2
9. if true execute the code, but this time its false so GO OUT of the loop and execute the code after going out which is "finished"

hope this helps!

mark it as solved if its been solved

commented: thines01 Already Explained it -1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.