title: How to use a while loop with an array?
body: <p>I've created a program that allows the user to enter 10 grades. I've used a while loop to store grades in the array, but if the user only has 5 grades to input, he can type done to exit the program. </p>
  
  <p>After the loop has finished, it will then calculate and display. the highest grade, lowest grade, and the average grade within the array</p>
  
  <p>Unfortunately, when the user types done, the program will display the rest of the grade lines that were not entered.</p>
  
  <p>Can you help me find out how to stop the while loop from displaying the rest of unentered grades of the loop?</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  int main()
  {
  const int SIZE = 10;
  int grade[SIZE];
  int count = 0;
  int lowestGrade;
  int highestGrade;
  bool done = false;
  
  
  cout &lt;&lt; "This program is limited to entering up to 10 grades." &lt;&lt; endl;
  
  while ( grade[count] != done &amp;&amp; count &lt; SIZE)
  {
  
      cout &lt;&lt; "Enter a grade #" &lt;&lt; count + 1 &lt;&lt; " or done to quit: ";
      cin &gt;&gt; grade[count];
      count++;
  
  }
  
  //LOWEST GRADE
  lowestGrade = grade[0];
  for (count = 0; count &lt; SIZE; count++)
      if (grade[count] &lt; lowestGrade)
      {
          lowestGrade = grade[count];
      }
  
  //HIGHEST GRADE
  highestGrade = grade[0];
  for (count = 0; count &lt; SIZE; count++)
  {
      if (grade[count] &gt; highestGrade)
      {
          highestGrade = grade[count];
      }
  }
  
  
  //AVERAGE GRADE
  double total = 0;
  double average;
  for (int count = 0; count &lt; SIZE; count++)
      total += grade[count];
  average = (total / SIZE);
  
  cout &lt;&lt; endl;
  
  cout &lt;&lt; "Your highest grade is: " &lt;&lt; highestGrade &lt;&lt; endl;
  cout &lt;&lt; "Your lowest grade is: " &lt;&lt; lowestGrade &lt;&lt; endl;
  cout &lt;&lt; "Your average grade is: " &lt;&lt; average &lt;&lt; endl;
  
  
  
  system("pause");
  return 0;
  
  }
  </code></pre>