The do-while loops is similar to the while loop except it will always go through the code in the loop at least once no matter what. Like the while loops it has three parts, the initialization of the variable in the condition, the testing of the variable(condition) and the change in the variable.
THe syntax of the do-while loop is:
do{
}while(condition);
The do-while loop isn’t as common as the other loops since it is similar to the while loop and its normally pretty simple to edit the condition for a while loop allow for the loop to always be gone through at least once.
One thought on “do-while”
Comments are closed.