title: Partially Filled Array C++
body: <p>Hi first time asking so sorry if I do anything wrong</p>
  
  <p>For my homework assignment I have to create a program that will ask the user to input up to 20 or less integers and it will output them in reverse order and give the largest and smallest integer in the array.  The user can enter less than 20 integers by terminating it with 0. I have most of it down, but I have a few questions.</p>
  
  <ol>
  <li><p>Part of the assignment states that if the user enters 20 integers it will automatically reverse the order, but in my program, the user has to enter 21 integers and then it will reverse it.</p></li>
  <li><p>When I try to figure out smallest value, it gives me a huge negative number like -76534534.</p></li>
  </ol>
  
  <p>Here is the code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  const int max_integers = 20;
  void intro( );
  void array(int array[], int size, int&amp; x);
  void reverse(const int array[], int x);
  void high(const int array[], int x);
  void low (const int array[], int x);
  int main( )
  {
      int input[max_integers];
      int x;
  
      intro( );
      array(input, max_integers, x);
      reverse(input, x);
      high(input, x);
      low(input, x);
      return 0;
  }
  
  void intro ( )
  {
      cout &lt;&lt; "This program will read in a list of integers and put them into an array." &lt;&lt; endl;
      cout &lt;&lt; "The maximum number of integers it will read in is 20.  The program will then " &lt;&lt; endl;
      cout &lt;&lt; "output the numbers in reverse order and give you the largest and smallest " &lt;&lt; endl;
      cout &lt;&lt; "integers." &lt;&lt; endl;
  }
  
  void array (int input[], int size, int&amp; x)
  {
      cout &lt;&lt; "Enter a list of integers (0 to end list).  Max number you can enter is " &lt;&lt; size &lt;&lt; "." &lt;&lt; endl;
      int next;
      int index = 0;
      cin &gt;&gt; next;
      while ((next &gt; 0) &amp;&amp; (index &lt; size))
      {
          input[index] = next;
          index++;
          cin &gt;&gt; next;
      }
      x = index;
      cout &lt;&lt; endl;
  }
  
  void reverse (const int input[], int x)
  {
      cout &lt;&lt; "The integers in reverse order are:" &lt;&lt; endl;
      for (int index = 0; x &gt; index; x--)
      {
          cout &lt;&lt; input[x-1];
          cout &lt;&lt; endl;
      }   
  }
  
  void high (const int input[], int x)
  {
      int high = 0;
      for (int index = 0; x &gt; index; x--)
      {
          if (input[x] &gt; high)
          {
              high = input[x];
          }
      }
  
      cout &lt;&lt; "The largest value entered is " &lt;&lt; high &lt;&lt; "." &lt;&lt; endl;
  }
  
  void low (const int input[], int x)
  {
      int low = 999999;
      for (int index = 0; x &gt;= index; x--)
      {
          if ((input[x] &lt; low) &amp;&amp; (low &gt; 0))
          {
              low = input[x];
          }
      }
  
      cout &lt;&lt; "The smallest value entered is " &lt;&lt; low &lt;&lt; "." &lt;&lt; endl;
  }
  </code></pre>