![]() When the condition check returns false, the loop body is not executed, and execution breaks out of the loop. ![]() After every execution of the loop body, condition is verified, and if it is found to be true the loop body is executed again. ![]() The sequence of statements to be executed is kept inside the curly braces known as the Loop body. After the loop is successfully executed the execution again starts from the Loop entry and again checks for the Test condition, and this keeps on repeating. The below diagram depicts a loop execution,Īs per the above diagram, if the Test Condition is true, then the loop is executed, and if it is false then the execution breaks out of the loop. In any programming language including C language, loops are used to execute a single statement or a set of statements, repeatedly, until a particular condition is satisfied. We can write the code statement as many times as we need it to execute but that would be very inefficient, because what if you want a code statement to execute a 100 times? This is why we use loops.
0 Comments
Leave a Reply. |