![]() ![]() After execution update expression is carried out. If it is true then control goes inside the body of the loop, otherwise, loop is terminated. Thus, it is easy to debug and also has no risk of forgetting any part of the loop, since the condition is checked before.įor loop is an entry-controlled loop as we check the condition first and then evaluate the body of the loop.įirstly Initialization expression is executed. It provides a concise way of writing initialization, test condition, and increment/decrement statements in one line. When we know the exact number of times the loop is going to run, we use for loop. Update expression doesn’t need to be increment or decrement only. And the next day we repeat the same process.Īs Sunday arrives we take a break from the routine, just like that when certain test condition fails, we come out of the loop. Then we complete the tasks, (eat-sleep-code) as in the body of the loop. For example, to attend online classes we check for a good internet connection. We test several possibilities, like availability of resources, pre-planned events, etc., to check whether we can complete the tasks. We wake up every morning and think of the tasks that we are going to accomplish in a day. To understand all these steps let us relate this to our day-to-day lives. It is also called Increment/Decrement expression since in most of the cases value of loop variables is either incremented or decremented. It is executed at the end of the loop when the loop-body has been executed and the next iteration is to start. It is used so that after some point of time the loop terminates.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |