title: Return index of smallest element in array
body: <p>I'm trying to return the index with the smallest element in an array of integers. Am I missing something? After I put my integers in, it doesn't return the index. </p>
  
  <p>UPDATE: I get an error at the end of <code>int main()</code> about the array stack being corrupted. Thank you. My code is as follows:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;conio.h&gt;
  
  using namespace std;
  
  int indexofSmallestElement(double array[], int size);
  
  int main()
  {    
  int size = 10; 
  double array[10];
  
  for (int i = 0; i &lt;= size; i++)
  {
      cout &lt;&lt; "Enter an integer: " &lt;&lt; endl;
      cin &gt;&gt; array[i];
  }
  
  indexofSmallestElement(array, size);
  }
  
  int indexofSmallestElement(double array[], int size)
  {
  int index = 0;
  
  if (size != 1)
  {
  
      int n = array[0];
      for (int i = 1; i &lt; size; i++)
      {
          if (array[i] &lt; n)
          {
              n = array[i];
              index = i;
          }
      }
  }
  return index;
  }
  </code></pre>