Do While loop Minimum Value

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
[code] "Please use code tags" [/code]
1
2
3
4
5
6
7
8
9
10
11
12
13
int i=0;
do{
//...
    i++; //first iteration i=1
    cin >> flag;
    test[i] = flag; //test[1]=flag
//...
}wihle( /**/ );

int max=test[0]; //test[0] has garbage
int min=test[0];

for(i=0;i<10;i++) //what if I didn't input 10 values? 
Topic archived. No new replies allowed.