+ 1

Can you explain me how they are different?

int i=0; while(i<=10){ // Something } int i=0; do{ // Something }while(i<=10);

17th Mar 2019, 3:35 AM
Zaw Moe Htike
Zaw Moe Htike - avatar
2 odpowiedzi
+ 2
Just to add to Serena Yvonne's answer, there is a chance that statements within a while loop won't be executed if the condition is not met. On the other hand, a do-while loop guarantees that the loop will execute at LEAST once.
17th Mar 2019, 4:18 AM
Lambda_Driver
Lambda_Driver - avatar