What is Do….While Loops?
The (do-while
loop) is a version of the while loop in which the state is assessed at the end of each loop iteration. A (while
loop) runs a block of code once and then evaluates the condition; if the condition is true, the expression is repeated as long as the condition is true.
Syntax:-
do {
code to be executed;
} while (condition is true);
Example:-
Output:-