title: Find the Average marks for each student
body: <p>There are 5 Students and 3 subjects.My problem is that when  the Average marks for each student are being calculated , the average marks  for the previous student is being added to the average marks calculated just after!
  Anyone could figure out what's wrong or what's missing in the piece of code please! Thank you :)</p>
  
  <pre><code>#include&lt;iostream&gt;
  using namespace std;
  int main ()
  {
      int i,j;
      double ave,scores,total=0.0;
  
      for(j=1;j&lt;=5;j++)
      {
          cout&lt;&lt;"Marks for Student"&lt;&lt;j&lt;&lt;":"&lt;&lt;endl;
          for(i=1;i&lt;=3;i++)
          {
              cout&lt;&lt;" subject"&lt;&lt;i&lt;&lt;":";
              cin&gt;&gt;scores;
              total+=scores;
          }
          ave=total/3;
          cout&lt;&lt;endl;
      }
      return 0;
  }
  </code></pre>