Home >Topic List >The difference between while loop and do while loop
The difference is: 1. The while loop judges the condition first and then executes the loop body, while the do-while loop executes the loop body first and then judges the condition; 2. The while loop judges the loop condition first, and if the condition is met, the loop body is executed. code, and then judge the condition again, and loop like this until the loop is jumped out when the condition is not satisfied. The do-while loop first executes the code in the loop body, and then judges whether the loop condition is satisfied. If the condition is satisfied, the loop continues to execute. The code in the body loops like this until the loop is jumped out when the condition is not met.