I have worked on this code for a while and I can get the maximum value to work,but not the minimum value. Any help would be greatly appreciated.
#include <iostream>
using namespace std;
int main()
{
char redo;
int i=0;
int test[10],sum=0,flag;
double ave;
do{
cout<<"Enter your score for test"<<i+1<<endl;
i++; cin >> flag;
test[i] = flag;
sum+=test[i];
ave=sum/i+1;
cout <<"Do you want to add another test score(Y/N)"<<endl;
cin>>redo;}
while(redo=='y'||redo=='Y');
cout<< "The average test score is:"<<ave-1<<endl;
int max=test[0];
int min=test[0];
for(i=0;i<10;i++){
if(test[i]>max)
max=test[i];
else if(test[i]<=min)
min=test[i];}
cout<<"Maximum number is: "<<max << endl;
cout<<"Minimum number is: "<<min<< endl;
cout<<endl;
cout<<"The averege of the tests without the minimum and maximum tests scores is:"<<sum-max-min/i-3<<endl;
system("pause");
return 0;
}
Last edited on