I try to modify the below code by using the Arrays but unable to success , would someone help me please. Thanks
//Outputs the lowest, highest, and average of inputted temperatures
//using an array structure
#include <cstdlib>
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
//input variables
float num = 0; // number of temps to be inputted
float temp = 0;
//processing variables
int counter = 0; // keeps track of index in array (outside loop)
float lowest = 0;
float highest = 0;
float sum = 0;
float avg = 0;
float temps[50] = {0}; // array of temperatures
//executable statements
cout << "How many number of temperature would you like to input: ";
cin >> num;
cout << "Please input temperature: ";
cin >> temp;
if (temp != -999)
{
while (counter <= num - 1)
{
temps[counter] = temp;
// Calculating lowest and highest temp
lowest = temps[counter];
highest = temps[counter];
int loop = 0; // counter for loop through indices in array
while (loop < num - 1)
{
if(temps[loop] < lowest)
{
lowest = temps[loop];
}
else // temps[t] >= lowest
{
if (temps[loop] > highest)
highest = temps[loop];
}
loop++;
}// end while
sum = sum + temp;
//Input another temperature
if (counter < num - 1)
{
cout << "Please input temperature: ";
cin >> temp;
}
counter++;
}//end while
//Calculating average
avg = sum/num;
//counter == num
cout << "The lowest temperature is: " << fixed;
cout << setprecision(2) << lowest << endl;
cout << "The highest temperature is: " << fixed;
cout << setprecision(2) << highest << endl;
cout << "The average temperature is: " << fixed;
cout << setprecision(2) << avg << endl;
}//end if
system("PAUSE");
return EXIT_SUCCESS;
}