/*--------------------------------------------------
created by st10 at Thu Dec  1 14:03:40 PST 2016
--------------------------------------------------*/
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;


/*--------------------------------------------------
 signature: smallest : double[] int -> double
 purpose: expects an array of values and its size, and
    returns the smallest value in that array.
    Returns 0.0 for an empty array (for an array of size
    0)

 examples: 
     const int NUM_VALS = 5;
     double vals[NUM_VALS] = {50, 2, 45.4, 22, 7};
 
     smallest(vals, NUM_VALS) == 2
 
     smallest(vals, 0) == 0.0
 
     const int NUM_WIDGETS = 4;
     double widg_hts[NUM_WIDGETS] = {-10, -11, 0, e};
 
 
     smallest(widg_hts, NUM_WIDGETS) == -11
--------------------------------------------------*/

double smallest(double values[], int size)
{
    double smallest_yet_seen;

    if (size <= 0)
    {
         return 0.0;
    }
    else
    {
        // make smallest yet seen start as the
	//    first element

        smallest_yet_seen = values[0];

        for (int i=0; i < size; ++i)
        {
            if (values[i] < smallest_yet_seen)
            {
                smallest_yet_seen = values[i];
            }
        }

        return smallest_yet_seen;
    }
}