next up previous contents index
Next: for Up: Control Structures Previous: while   Contents   Index


do

do is similar to while except that the continuation condition is tested at the end of the loop rather than at the beginning; it follows that the body of the loop is certain to be executed at least once:

  
int a[10];
int i;
/* .. */
i=0;
do {  /*  write out the initial increasing segment of a  */
   printf("%d", a[i]);
   i = i+1;
} while (i<9 && a[i] >= a[i-1]) 



CATAM admin 2010-02-23