WHILE Statements

WHILE loops are automatically shown in the diagram when there are annotated actions inside. (The zoom level for the loop will correspond to the greater zoom level of all actions).
We may add a user-defined condition description for the loop before the WHILE-statement. We may also quote the calls to functions/methods in the loop-condition so that they appear in the diagram.

annotation

      //$ [loop condition user-description] 
      while (while condition) {    //$ 
      //$ action 1
      code
      } 
      

OPTIONAL:
//$: forces displaying in the diagram the calls to functions/methods inside the conditionStatement
//$ [condition user-description]: specifies a user-description of the condition; the square brackets [ ] are required syntax

representation in the diagram

figure

examples

using namespace std;

void function(int a){
int x = 0;
while (x < 5) 
  {
    //$ print x and add one unit to x.
    printf ("x = %d\n", x);
    x++;
  }
return;
}
      figure