title: Finding average GPA C++
body: <p>This is probably a stupid question.
  I am fairly new to programming.</p>
  <p>I am trying to find the average GPA of each student. The first for loop I have will list the student name then go into a nested for loop which has you enter a letter grade 10 times. Once they enter the letter grade, depending on what letter it is the if/else statements turn it into a number which then adds it to the array arr[100]. After you enter 10 grades for one students it displays the average gpa.</p>
  <p>The issue I am having is that once you enter the 10 grades for the first student it find the GPA just fine. However, once you get to the second student it is adding the first students average GPA to the 2nd students and so on.</p>
  <p>How should I go about fixing this?</p>
  <p>Thanks!</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;iomanip&gt;
  
  using namespace std; 
  
  
  int main() {
      float sum = 0.0, average;
      int y;
      string grades;
      float arr[100];
      string totalStudents[10] = {&quot;Malcolm 'Mal' Reynolds&quot;, &quot;Inara Serra&quot;, &quot;River Tam&quot;, &quot;Kaylee Frye&quot;, &quot;Zoe Washburne&quot;, &quot;Jayne Cobb&quot;, &quot;Hoban 'Wash' Washburne&quot;, &quot;Simon Tam&quot;, &quot;Shepherd Derrial Book&quot;, &quot;Mr. Universe&quot;};
  
      for (int i=0; i &lt; sizeof(totalStudents); i++) {
          cout&lt;&lt;&quot;Please enter grades for &quot; &lt;&lt; totalStudents[i] &lt;&lt;endl;
          for (int y = 0; y &lt; 10; y++) {
              cout &lt;&lt; &quot;Enter letter grade &quot; &lt;&lt; y + 1 &lt;&lt; &quot;:&quot;&lt;&lt; endl;
              cin &gt;&gt; grades;
  
              if (grades == &quot;A&quot; || grades == &quot;a&quot;) {
  
                  arr[y] += 4;
  
              }else if (grades == &quot;B&quot; || grades == &quot;b&quot;) {
                  arr[y] += 3;
              }else if (grades == &quot;C&quot; || grades == &quot;c&quot;) {
                  arr[y] += 2;
              
              }else if (grades == &quot;D&quot; || grades == &quot;d&quot;) {
                  arr[y] += 1;
  
  
              }else if (grades == &quot;F&quot; || grades == &quot;f&quot;) {
                  arr[y] += 0;
              
  
          }
  
              sum += arr[y];
  
          
           }
  
              average = sum/10;
              cout &lt;&lt; totalStudents[i] &lt;&lt; &quot; GPA is: &quot; &lt;&lt; fixed &lt;&lt; setprecision(1) &lt;&lt; average &lt;&lt; endl;
  
  
  
      }
  
  
  
      }
  </code></pre>