Source of Exercise01.cpp


  1: //  Created by Frank M. Carrano and Timothy M. Henry.
  2: //  Copyright (c) 2017 Pearson Education, Hoboken, New Jersey.

  4: int getNumberEqual(const int x[], int n, int desiredValue)
  5: {
  6:    int count = 0;
  7:    
  8:    if (n <= 0)
  9:       return 0;
 10:    else
 11:    {
 12:       if (x[n - 1] == desiredValue)
 13:          count = 1;
 14:       
 15:       return getNumberEqual(x, n - 1, desiredValue) + count;
 16:    }  // end else
 17: }  // end getNumberEqual