It is a conditional looping statement that checks a condition and then repeats the statements number of times till the conditional is true. There are two ways of using DO WHILE LOOP.
They are:
- DO WHILE-LOOP
Syntax
DO WHILE <Condition>
<Block of statements>
LOOP
- DO - LOOP WHILE
Syntax
DO
<block of statements>
LOOP WHILE <condition>
Note: There difference between two types is - in first type it checks the condition and then executes statements. LOOP statements sends control back to the do while. This is also called as PRE-TEST loop check.
In second syntax, First it executes the statements and then checks whether the condition is true or false. If the condition is true it continues, If its false then terminates the loop. It means whether the condition is true or false it executes the statement at least once. This is also called as POST-TEST loop check.