title: Find largest and smallest number in an array
body: <p>Consider:</p>
  
  <pre><code>#include &lt;iostream&gt; // Include header file
  
  using namespace std;
  
  int main () //start of main function
  {
  
      int values[20]; // Declares array and how many elements
      int small, big; // Declares integer
      big = small = values[0]; // Assigns element to be highest or lowest value
  
      for (int i = 0; i &lt; 20; i++) // Counts to 20 and prompts the user for a value and stores it
      {
          cout &lt;&lt; "Enter value " &lt;&lt; i &lt;&lt; ": ";
          cin &gt;&gt; values[i];
      }
  
      for (int i = 0; i &lt; 20; i++) // Works out the biggest number
      {
          if(values[i] &gt; big) // Compare biggest value with current element
          {
              big = values[i];
          }
      }
  
      for (int i = 0; i &lt; 20; i++) // Works out the smallest number
      {
          if (values[i] &lt; small) // Compares smallest value with current element
          {
              small = values[i];
          }
      }
  
      cout &lt;&lt; "The biggest number is " &lt;&lt; big &lt;&lt; endl; // Prints outs the biggest number
      cout &lt;&lt; "The smallest number is " &lt;&lt; small &lt;&lt; endl; // Prints out the smallest number
  }
  </code></pre>
  
  <p>This is my code so far. The problem I am having is with it printing out the biggest number of the array. Something to do with assigning the first element to the highest and lowest value. It works if I do them separately. Any suggestions?</p>