cout<<"HIGHEST SCORE IS: "<<largest<<name[i]<<endl;
cout<<"LOWEST SCORE IS:"<<smallest<<name[i+1]<<endl;
cout<<"AVERAGE IS:"<<average;
system("PAUSE");
and heres the problem
. write a program that allows the user to enter students name followed by their test score. it will first ask how many students to enter, then asks the students name followed by their score. it will then output the average of all scores, & the student w/ the highest & lowest test score. use one dimensional array for students name & another array for the score
save as prelim3-class score
expected output
how many student?2
enter student #1 name:tony
enter sruden tscore 50
enter student #1 name:t
enter sruden tscore 100
the highest score is t
the lowest score is tony
average is
To find the average you should add up all the scores, then divide by the number of scores.
Declare an int scoreSum = 0;
Then, in either of your for loops add up the values:
scoreSum += score[i];
After adding all values you can find: average = scoreSum/hn;
You still need to declare a size for the scores array. int score[]={}; isn't going to work out.
hmmm, i think why the average didn't work because of the last part
cout<<"HIGHEST SCORE IS: "<<name[i]<<endl;
cout<<"LOWEST SCORE IS:"<<name[0]<<endl;
i dont if this is the w <<name[0];
example of my output
how many student?2
enter student #1 name:james
enter ssuden score :50
enter student #1 name: little hey
enter sruden tscore :100
the highest score is: little hey
the lowest score is: james
average is:50
but when i enter this
how many student?2
enter student #1 name:james
enter ssuden score :100
enter student #1 name: little hey
enter sruden tscore :50
the highest score is: little hey
the lowest score is: james
average is:25
i think it is because of name[0];
what should i do???
when i enter it would be like this
ENTER MANY many students?2
ENTER name of students:hey
ENTER EMUH SCORE:3
ENTER name of students:ii
ENTER EMUH SCORE:6
HIGHEST SCORE IS:6
LOWEST SCORE IS:0
hhhmmm???