The reason for this is as follows
So far, the loop is executing in accordance with the expression it provides. If the expression is true, then the statement written during {} will execute differently. You can also tag ; after while (expression); , but it will just populate the while syntax right away, since ; indicates the end of the statement. In general, whil e loop checks the expression and executes a list of instructions inside.
Do While condition : - You have a signature, for example
do statement while (expression);
do-while is an interesting loop. It has the specialty that statements following a do will be executed at least regardless of whether the expression in while true or false. The do while thread says that the statement following the do will be executed once, and then the while condition is checked. If the while condition is true, the statements following do again. The reason it exists ; at the end of do ... while (expression); , lies in the fact that while considered here as a statement, since its body is above it. In C ++, every statement must end in ; , so do while ends with ; .
source share