int rows,cols,i,j;
double score[100][100],sum=0.00,ave=0.00,max=0.00,min=0.00;
char retry;
cout<<"Enter rows: ";
cin>>rows;
cout<<endl;
cout<<"Enter column: ";
cin>>cols;
cout<<endl;
cout<<"You will enter "<<rows*cols<<" elements in a ["<<rows<<"]x"<<"["<<cols<<"] matrix";
cout<<endl<<endl;
// loop for score input//
for ( i=0;i<rows;i++)
{
for ( j=0;j<cols;j++)
{
do
{
cout<<"["<<i<<"]["<<j<<"] :";
cin>>score[i][j];
sum+=score[i][j]; //computes score sum for average
}
while(score[i][j]<0.00 || score[i][j]>100.00);
}
cout<<endl;
}
cout<<endl<<endl;
cout<<"You entered: "<<endl;
//loop for score output//
for ( i=0;i<rows;i++)
{
for ( j=0;j<cols;j++)
{
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout<<setw(5)<<score[i][j]<<"\t";
}
cout<<endl;
}
ave=sum/(rows*cols); // computes average
cout<<endl;
cout<<"The average mean score is: "<<ave;
//loop for sorting highest and lowest//
for ( i=0;i<rows;i++)
{
for ( j=0;j<cols;j++)
{
if (score[i][j]>max)
{
max=score[i][j];
}
if (score[i][j]<min)
{
min=score[i][j];
}
}
cout<<endl;
}
cout<<"The highest score is: "<<max;
cout<<endl;
cout<<"The lowest score is: "<<min;
cout<<endl;
cout<<endl;
cout<<endl;
cout<<"Do you wish to try again?"<<endl<<endl;
do
{
cout<<"Press Y to try again or N to go back to MENU: ";
cin>>retry;
toupper(retry);
}
while ( toupper(retry)!='Y' && toupper(retry)!='N');
if (toupper(retry)=='Y')
{
scores();
}
else
{
menu();
}
i tried running it over and over but i cant seem to get it to display the lowest value entered, it always displays 0.00,
cout<<"The average mean score is: "<<ave;
//loop for sorting highest and lowest//
/***********************************************************************/
min = score[0][0]; //You forgot this
/***********************************************************************/
for ( i=0;i<rows;i++)
{
for ( j=0;j<cols;j++)
{
if (score[i][j]>max)
{
max=score[i][j];
}
if (score[i][j]<min)
{
min=score[i][j];
}
}