title: Highest and Lowest Integer C++
body: <p>when I run this program is a "Run-Time Check Failure #2 stack around the variable 'numGrades' was corrupted" appears. Also the lowest grade doesn't output the correct answer. Any help would be greatly appreciated! </p>
  
  <pre><code>#include &lt;iostream&gt; // cin, cout
  
  using namespace std;
  
  const int TEN_GRADES = 10;   // pre-defined number of grades
  
  int main()
  {
      int numGrades[10];
      double avg, highest = numGrades[0], lowest = numGrades[0], less, greater, grades;
      double sum = 0;
  
      // greeting message
      cout &lt;&lt; "---------------------------------" &lt;&lt; endl
           &lt;&lt; "  Sandro's Statistics Generator  " &lt;&lt; endl
           &lt;&lt; "---------------------------------" &lt;&lt; endl &lt;&lt; endl;
  
      // requesting number of grades 
      cout &lt;&lt; "Hello Professor, how many grades do I need to analyse this time? ";
      cin &gt;&gt; numGrades[10];
  
      if (numGrades[1] == 0)
      {
          cout &lt;&lt; "\nGuess you changed your mind!!!" &lt;&lt; endl
               &lt;&lt; "Ending program now..." &lt;&lt; endl &lt;&lt; endl;
          return 0;
      }
  
      // if user doesn't enter 0 user is ready to begin
      cout &lt;&lt; "Okay, I am ready. Start..." &lt;&lt; endl;
      for (int count = 0; count &lt; numGrades[10]; count++)
      {
          cin &gt;&gt; numGrades[count];
          sum += numGrades[10];
      }
  
      // to get the average
      avg = sum / TEN_GRADES;
  
      // to get the highest and lowest mark
  
      for (int count = 0; count &lt; TEN_GRADES; count++)
      {
          if (numGrades[count] &gt; highest)
              highest = numGrades[count];
      }
  
      for (int count = 0; count &lt; TEN_GRADES; count++)
      {
          if (numGrades[count] &lt; lowest)
              lowest = numGrades[count];
      }
  
      // output requested statistics
      cout &lt;&lt; "Here are the requested stats for the " &lt;&lt; numGrades &lt;&lt; " grades."     &lt;&lt; endl
           &lt;&lt; "The class average is " &lt;&lt; avg &lt;&lt; endl
           &lt;&lt; "The highest grade is " &lt;&lt; highest &lt;&lt; endl
           &lt;&lt; "The lowest grade is " &lt;&lt; lowest &lt;&lt; endl;
  
      return 0;
  </code></pre>
  
  <p>}</p>