Home Segments Index Top Previous Next

306: Mainline

For example, the following function fragment repeatedly decrements n by 1 until n is 0:

while (n != 0) 
  n = n - 1; 

Replacement of the single embedded statement, n = n - 1;, by a compound statement enables the while statement to do useful computation while counting down n to 0.