[Solved] Find the Average marks for each student


You’re not “zeroing out” your total counter when moving on to the next average computation. This is a trivial problem that you would be able to solve if stepping through the code line by line.

If you don’t practice this now, it’ll be incredibly difficult to solve more complex problems. Next question you ask, please post what you have tried.

#include<iostream>
using namespace std;
int main ()
{
int i,j;
double ave,scores,total=0.0;

 for(j=1;j<=5;j++)
     {
      cout<<"Marks for Student"<<j<<":"<<endl;
         for(i=1;i<=3;i++)
            {
               cout<<" subject"<<i<<":";
                cin>>scores;
                total+=scores;
            }
       ave=total/3;

       // Changes here
       cout<<"average:" << ave << endl; // print it here
       ave=0; // zero it out

       cout<<endl;
     }
   return 0;
}

solved Find the Average marks for each student