Home Segments Index Top Previous Next

367: Practice

Temporarily suspending disbelief, convert the program that you wrote in Segment 355 into a program consisting of three cooperating functions, factorial, base, and recurse. The factorial function is to look like this:

int factorial (n) { 
  if (n == 0) 
    return base (); 
  else 
    return recurse (n); 
} 

The recurse function is to call the factorial function, thus requiring you to use at least one function prototype.