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.

Attachments loop_sequence_question.PNG 63.16 KB
6 Years
Discussion Span
Last Post by anthonyjpv

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.

Votes + Comments
Good man

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

Votes + Comments
thines01 Already Explained it
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.