Answer to Question 14B-1

// FirstPositive(A, n) returns the first positive
// number in array A[0,...,n-1].  If none of those
// numbers are positive, firstPositive returns 0.

int firstPositive(const int A[], const int n)
{
  for(int i = 0; i < n; i++)
  {
    if(A[i] > 0)
    {
      return A[i];
    }
  }
  return 0;
}