title: How can I find the highest and lowest values in this array?
body: <p>What code can I use to print out the highest and lowest values that the user inputs in this array? This program needs to take the average of the user input (which I've already done). Now all I need to do is have the program print out the highest and lowest values that the user input.</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  int main()
  {
  float days = 0;
  float temperatures [50];
  float temptotal = 0;
  float average = 0; 
  cout &lt;&lt; "Enter the number of days: ";
  cin &gt;&gt; days;
  if (days &gt; 50)
  {
      cout &lt;&lt; "You may only enter temperatures for 50 days." &lt;&lt; endl;
      return 0;
  }
  for (int i = 1; i &lt;= days; i++)
  {
      cout &lt;&lt; "Enter the temperature for day number " &lt;&lt; i &lt;&lt; ": "; 
      cin &gt;&gt; temperatures[50];
      temptotal += temperatures[50]; 
  }
  average = (temptotal / days);
  cout &lt;&lt; "The temperature average is: " &lt;&lt; average &lt;&lt; endl;
  return 0;
  }
  </code></pre>