In a while loop, if the condition is not true, then the body of a loop will not be executed, not even once. Once the condition becomes false, the control goes out of the loop. If it is true, the same process is executed until the condition becomes false. If a condition is true, then and only then the body of a loop is executed.Īfter the body of a loop is executed, the control again goes back to the beginning, and the condition is checked. In a while loop, a condition is evaluated before processing a body of the loop. What is While Loop?Ī While loop is the most straightforward looping structure. The purpose of the loop is to repeat the same code a number of times. The control statement is a combination of some conditions that direct the body of the loop to execute until the specified condition becomes false. A loop consists of two parts, a body of a loop and a control statement. A Loop executes the sequence of statements many times until the stated condition becomes false.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |