Hey all, I have an array in which the user inputs a series of numbers and when "-1" is entered the program is stopped and the average, max, and min of the numbers entered is displayed. I am able to get the average and max but for some reason the min is displaying "0" all the time. I'm not sure if its a stupid mistake that I am missing or not. Can anyone please point me in the right direction?
#include <iostream>
using namespace std;
int main()
{
double scores[75];
int counter = -1;
do
{
counter++;
cout << "Please enter a score (enter -1 to stop): ";
cin >> scores[counter];
} while (scores[counter] >= 0);
double sum = 0;
double average = 0;
double max = 0;
double min = 0;
for (int x = 0; x < counter; x++)
{
sum += scores[x];
}
average = sum / counter;
cout << "Average is " << average << endl;
for (int x = 0; x < counter; x++)
{
if (scores[x] > max)
max = scores[x];
}
cout << "Highest is " << max << endl;
for (int x = 0; x < counter; x++)
{
if (scores[x] < min)
min = scores[x];
}
cout << "Lowest is " << min << endl;
}