title: Finding smallest value in array using functions?
body: <p>Hello so currently I am trying to work on a project, but I have run into a roadblock and i've been staring at this code for hours and can't figure out what's going on.</p>
  
  <p>My main issue is finding the smallest value of the array in which the user has entered... I was able to get the largest value and output that, but for some reason I can't get the smallest value to output the correct result. I keep getting 0.0....</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #define SIZE 5
  double getValidRainfall() {
  double result;
  
  printf("\nEnter a rainfall amount: ");
  scanf("%lf", &amp;result);
  
  while (result &lt; 0.0) {
      printf("%.2lf is not a valid rainfall amount.", result);
      printf("\nEnter another rainfall amount: ");
      scanf("%lf", &amp;result);
  }
  return result;
  }
  double calculateTotal(double rainfall[], int size) {
  double result = 0.0;
  int i;
  for (i = 0; i &lt; SIZE; i++) {
      result += rainfall[i];
  }
  return result;
  }
  
  double findLargest(double rainfall[], int size) {
  double result = 0.0;
  int i;
  for (i = 0; i &lt; size; i++) {
      if (rainfall[i] &gt; result)
          result = rainfall[i];
  }
  return result;
  }
  
  double findSmallest(double rainfall[], int size) {
  double result = 0.0;
  int i;
  
  for (i = 0; i &lt; size; i++) {
      if (rainfall[i] &lt; result) 
          result = rainfall[i];
  }
  return result;
  }
  
  main() {
  double rainfall[SIZE], totalRainfall, averageRainfall;
  double largestRainfall, smallestRainfall;
  int i;
  
  for(i = 0; i &lt; SIZE; i++)
      rainfall[i] = getValidRainfall();
  
  totalRainfall = calculateTotal( rainfall, SIZE );
  averageRainfall = totalRainfall / SIZE;
  largestRainfall = findLargest(rainfall, SIZE);
  smallestRainfall = findSmallest(rainfall, SIZE);
  
  
  // outputs
  printf("\nThank you.\n");
  printf("The total rainfall for these 5 days is: %.2lf\n", totalRainfall);
  printf("The average rainfall is %.2lf\n", averageRainfall);
  printf("The largest daily rainfall is %.1lf\n", largestRainfall);
  printf("The smallest daily rainfall is %.1lf\n", smallestRainfall);
  
  system("pause");
  }
  </code></pre>