Source of Exercise14.cpp


  1: //  Created by Frank M. Carrano and Tim Henry.
  2: //  Copyright (c) 2013 __Pearson Education__. All rights reserved.

  4: int f(int n);

  6: int main()
  7: {
  8:    cout << "The value of f(8) is " << f(8) << endl;
  9:    return 0;
 10: }  // end main

 12: /** @pre n >= 0. */
 13: int f(int n)
 14: {
 15:    cout << "Function entered with n = " << n << endl;
 16:    switch (n)
 17:    {
 18:       case 0: case 1: case 2:
 19:          return n + 1;
 20:       default:
 21:          return f(n-2) * f(n-4);
 22:    }  // end switch
 23: }  // end f