title: calculate average of array elements and display them
body: <p>The problem is: 
  A Class of 40 students has received their grades for 5 exams. Implement a function that calculates the worst average grade and display the the IDs of all students having the worst average grade.‎</p>
  
  <p>I already calculated the average but do not know how to calculate the WORST average ( as in the lowest average of the 40 students) and displaying the ID numbers that have this number.</p>
  
  <p>This is what I have written so far: </p>
  
  <pre><code>#include&lt;iostream&gt;
  #include &lt;iomanip&gt;
  using namespace std;
  const int MAX_NUM = 6;
  int x[MAX_NUM];
  int y[5];
  
  int main()
  {
  
  
  float avg;
  float total = 0;
  
  for (int i = 0; i &lt; MAX_NUM; i++)
  {
      cout &lt;&lt; "Enter an ID number: " &lt;&lt; endl;
      cin &gt;&gt; x[i];
      cout &lt;&lt; "Enter 5 grades: " &lt;&lt; endl;
      for (int j = 0; j &lt; 5; j++)
      {
          cin &gt;&gt; y[j];
          while (y[j]&gt;100)
          {
              cout &lt;&lt; "Please enter a valid grade that is less than a 100: " &lt;&lt; endl;
              cin &gt;&gt; y[j];
          }
          total += y[j];
      }
          avg = total / 5;
  
      cout &lt;&lt; "ID: " &lt;&lt; x[i] &lt;&lt; endl;
      cout &lt;&lt; "Average: "&lt;&lt; avg &lt;&lt; endl;
  }
  </code></pre>