int find_smallest (int data[], int n) { int i, smallest; // start of by assuming that the first value is our smallest value. // this is cleaner than using INT_MAX (which does work) and much // better than using an arbitrary value like zero (which doesn't work // if all of the values are greater than the value chosen) smallest = data[0]; // now consider all of the remaining values (note: i starts at 1) for (i = 1; i < n; i++) { if (data[i] < smallest) { smallest = data[i]; // we have a new champion } } return smallest; } void analyze_murders (double murders[], int years, int &big_ups, int &big_downs) { int i; double increase; big_ups = big_downs = 0; // nothing seen so far for (i = 0; i < years - 1; i++) { // the following will cause a problem if muders[i] is zero, // but the nature of New York is such that this is impossible. // note the order of operations and the use of 100.0 instead of 100 // (there is a danger here of getting integer division and this isn't // what is called for). increase = ((murders[i + 1] - murders[i]) * 100.0) / murders[i]; if (increase >= 5.0) { big_ups++; } else if (increase <= -5.0) { big_downs--; } } }