// Display the average value of the intergers entered
long double average; // datatype for average
double total = 0; // Accumulator
for (count = 0; count < TEN_INTEGERS; count ++)
total += integers [count];
{
average = total / TEN_INTEGERS;
cout << "\nThe average value of the integers entered is: " <<
average << endl;
}
// Display the highest value of the integers entered
long int highest; // datatype for highest integer value
highest = integers [0];
for (count = 0; count < TEN_INTEGERS; count++)
{
if (integers [count] > highest)
highest = integers [count];
{
cout << "\nThe highest value of the integers entered is: " << highest << endl;
}
}
// Display the lowest value of the integers entered
long int lowest = integers [0]; // datatype for the lowest integer value
for (count = 0; count < TEN_INTEGERS; count++)
{
if (integers [count] < lowest)
lowest = integers [count];
{
cout << "\nThe lowest value of the integers entered is: " << lowest << endl;
}
}
return 0;
}
I am able to prompt the user for ten integers, and the average is calculated perfectly, but the highest and lowest values are giving me trouble. It displays ten values for the highest and lowest values when I only want one displayed for each...the highest and lowest value out of the ten integers...Please help