title: smallest value of array
body: <p>I'm trying to write a function that will return the smallest value of an array. So far I have this, but all it returns is 0. </p>
  
  <p>I don't see how it would return 0 since I am using a for loop to cycle through the array. Perhaps it is not cycling through the arrays values as I would think it does. Can anyone elaborate on the logic and the fallacy in this code?</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  int newArray[9] = {4,5,9,3,6,2,1,7,8};
  
  
  int minArray()
  {
      int index = 1;
      int minimum;
  
      for (int i = 0; i &lt; 9; i++)
      {
          if (newArray[i] &gt; newArray[index])
          {
              minimum = newArray[index];
          }
          index++;
  
      }
  
      return minimum;
  }
  
  
  int main()    
  {   
      cout &lt;&lt; "original array:\n ";
      for (int i = 0; i &lt; 9; i++)
      {
          cout &lt;&lt; newArray[i] &lt;&lt; ", ";
      }
  
      cout &lt;&lt; "minimum value of array: ";
      cout &lt;&lt; minArray();
  
      return 0;
  }
  </code></pre>