post-test loop is the loop which executes once before condition is checked.
post-test loop is the loop which executes once before condition is checked.
the loop which execute once before condition is checked?
post-test loop
the "do while" construct consists of a process symbol and a condition. first, the code within the block is executed, and then the condition is evaluated. if the condition is [[truth|true]] the code within the block is executed again. this repeats until the condition becomes [[false (logic)|false]]. because do while loops check the condition after the block is executed, the control structure is often also known as a post-test loop. contrast with the [[while loop]], which tests the condition before the code within the block is executed, the do-while loop is an exit-condition loop. this means that the code must always be executed first and then the expression or test condition is evaluated. if it is true, the code executes the body of the loop again. this process is repeated as long as the expression evaluates to true. if the expression is false, the loop terminates and control transfers to the statement following the do-while loop. in other words, whereas a while loop sets the truth of a statement as a [[condition precedent]] for the code's execution, a do-while loop provides for the action's ongoing execution subject to defeasance by the condition's falsity, which falsity ("i.e.", the truth of the condition's negation) is set as a [[condition subsequent]].
do while loop
although the calculation codice_1 and codice_2 is loop-invariant, precautions must be taken before moving the code outside the loop. it is possible that the loop condition is codice_3 (for example, if codice_4 holds a negative value), and in such case the loop body should not be executed at all. one way of guaranteeing correct behaviour is using a conditional branch outside of the loop. it should also be noted that evaluating the loop condition can have side effects, so an additional evaluation by the codice_5 construct should be compensated by replacing the codice_6 loop with a codice_7. if the code used codice_7 in the first place, the whole guarding process is not needed, as the loop body is guaranteed to execute at least once.
loop-invariant code motion