while(condition_is_true){do something;
if(goal_achivied)do something to halt the loop}
ex:
1 2 3
n=1;
while(n<10){n++;} //this when n is smaller than 10, it will execute n++ until it reach 9 and stop
1 2 3
while(n>0){do something here ;//as long as n is bigger than 0}
if(goal_finished){do something here;
break; //to halt loop}
while(condition){do .... }
so as long as the condition is TRUE, then it will executed to do something. And if the condition is FALSE, then it will stop to executing the program, and skip it.