Code://This program asks the user to pick the number of test //scores they wish to average, drops the lowest(returning //'lowestscore'and showing it) and then it calculates the //average minus the lowestscore). Could someone please //take a look and let me know how to fix it. THANKS !!! #include <iostream> using namespace std; int calcaverage(int *[], int *[]); int findlowest(int *[], int *[]); int main() { int HowMany; cout<<"How many scores do you wish to input?"; cin>>HowMany; int *Scores = new int[HowMany]; cout<<"Enter your "<<HowMany<<" scores.\n"; for (int i=0; i<HowMany; i++) { cout<<"\t"<<i+1<<": "; cin>>Scores[i]; } return 0; } //This function finds the average. int calcaverage(int HowMany, int *Scores) { int a=findlowest(int HowMany, int *Scores); int total=0; int average=0; { for(int i=1; i<HowMany; i++) total += Scores[i]; } total -= a; HowMany--; average = total/HowMany; cout<<"Your test average is: "<<average; } //This function finds the lowest score and returns it. int findlowest(int HowMany, int *Scores) { int lowestscore = Scores[0]; { for(int i=1; i<HowMany; i++) if(Scores[i]<lowestscore) lowestscore=Scores[i]; } return lowestscore; }



LinkBack URL
About LinkBacks


