previous | index | next

The while Statement

Here is the full flow of control for the factorial function:

int factorial(int n)
{
  int p = 1;
  while ( n > 0 ) {
    p = p*n;
    n = n-1;
  }
  return p;
}

previous | index | next