find the averages for each athlete

I have to find the average of each athlete.But with my program ,the sum of the score score doubles up .And it affects my average of each athlete.How can I get an Average of each athlete with this program. Any suggestion Please?:{

#include <iostream>

using namespace std;

int main()

{


int id,judge,highest,lowest;
double score[10]; //store 10 elements
double average;
double sum=0; //initialize it to 0

do{
cout<<"Enter the id number of an athlete: ";
cin>>id;
cout<<"Enter the judges number: ";
cin>>judge;
for(int i=0;i<judge;i++){

cout<<"Score :";
cin>>score[i];

sum+=score[i];

highest=score[0];
lowest=score[0];


for(int j=0;j<10; j++){

if(score[i]>highest)
highest=score[i];
if(score[i]<lowest)
lowest=score[i];


average=(sum-(highest+lowest))/ judge; //formula for average wiyhout highest and lowest score;

}



}

cout<<sum<<endl;
cout<<"average: "<<average<<endl;
cout<<endl;

}while (id>=0);

return 0;
try to take out the average code out of for loop and then calculate it... It may help

PS: please use code tags
http://www.cplusplus.com/articles/jEywvCM9/

Change the average formula
Topic archived. No new replies allowed.